snapshot_download

class swift.hub.snapshot_download.snapshot_download(model_id, revision=None, cache_dir=None, user_agent=None, local_files_only=False, cookies=None, ignore_file_pattern=None)[源代码]

Download all files of a repo. Downloads a whole snapshot of a repo's files at the specified revision. This is useful when you want all files from a repo, because you don't know which ones you will need a priori. All files are nested inside a folder in order to keep their actual filename relative to that folder.

An alternative would be to just clone a repo but this would require that the user always has git and git-lfs installed, and properly configured.

参数:
  • model_id (str) -- A user or an organization name and a repo name separated by a /.

  • revision (str, optional) -- An optional Git revision id which can be a branch name, a tag, or a commit hash. NOTE: currently only branch and tag name is supported

  • cache_dir (str, Path, optional) -- Path to the folder where cached files are stored.

  • user_agent (str, dict, optional) -- The user-agent info in the form of a dictionary or a string.

  • local_files_only (bool, optional) -- If True, avoid downloading the file and return the path to the local cached file if it exists.

  • cookies (CookieJar, optional) -- The cookie of the request, default None.

  • ignore_file_pattern (str or List, optional, default to None) -- Any file pattern to be ignored in downloading, like exact file names or file extensions.

抛出:

ValueError -- the value details.

返回:

Local folder path (string) of repo snapshot

返回类型:

str

备注

Raises the following errors: - [EnvironmentError](https://docs.python.org/3/library/exceptions.html#EnvironmentError) if use_auth_token=True and the token cannot be found. - [OSError](https://docs.python.org/3/library/exceptions.html#OSError) if ETag cannot be determined. - [ValueError](https://docs.python.org/3/library/exceptions.html#ValueError) if some parameter value is invalid