model_file_downloadο
- class swift.hub.file_download.model_file_download(model_id, file_path, revision=None, cache_dir=None, user_agent=None, local_files_only=False, cookies=None)[source]ο
Download from a given URL and cache it if itβs not already present in the local cache.
Given a URL, this function looks for the corresponding file in the local cache. If itβs not there, download it. Then return the path to the cached file.
- Parameters:
model_id (str) β The model to whom the file to be downloaded belongs.
file_path (str) β Path of the file to be downloaded, relative to the root of model repo.
revision (str, optional) β revision of the model file to be downloaded. Can be any of a branch, tag or commit hash.
cache_dir (str, Path, optional) β Path to the folder where cached files are stored.
user_agent (dict, str, 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. if False, download the file anyway even it exists.
cookies (CookieJar, optional) β The cookie of download request.
- Returns:
string of local file or if networking is off, last version of file cached on disk.
- Return type:
string
- Raises:
NotExistError β The file is not exist.
ValueError β The request parameter error.
Note
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