ensure_from_google

ensure_from_google(key: str, *subkeys: str, name: str, file_id: str, force: bool = False) Path[source]

Ensure a file is downloaded from google drive.

Parameters:
  • key – The name of the module. No funny characters. The envvar <key>_HOME where key is uppercased is checked first before using the default home directory.

  • subkeys – A sequence of additional strings to join. If none are given, returns the directory for this module.

  • name – The name of the file

  • file_id – The file identifier of the google file. If your share link is https://drive.google.com/file/d/1AsPPU4ka1Rc9u-XYMGWtvV65hF3egi0z/view, then your file id is 1AsPPU4ka1Rc9u-XYMGWtvV65hF3egi0z.

  • force – Should the download be done again, even if the path already exists? Defaults to false.

Returns:

The path of the file that has been downloaded (or already exists)

Example downloading the WK3l-15k dataset as motivated by https://github.com/pykeen/pykeen/pull/403:

import pystow

path = pystow.ensure_from_google(
    "test", name="wk3l15k.zip", file_id="1AsPPU4ka1Rc9u-XYMGWtvV65hF3egi0z"
)