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)[源代码]
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.
- 参数:
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.
- 返回:
string of local file or if networking is off, last version of file cached on disk.
- 返回类型:
string
- 抛出:
NotExistError -- The file is not exist.
ValueError -- The request parameter error.
备注
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