tensorplay.hub
Functions
download_url_to_file() [source]
python
download_url_to_file(url: str, dst: Union[str, pathlib._local.Path], hash_prefix: Optional[str] = None, progress: bool = True, timeout: float = 10.0, max_retries: int = 3, overwrite: bool = False, allow_resume: bool = True, user_agent: str = 'TensorPlay/1.0 (Python/3.13; win32)') -> NoneDownload a URL to a local file(Safe download: temp file + hash check + progress feedback).
Features:
- First download to a temp file, then move to the destination path to avoid corrupting the destination file.
- Support SHA256 hash prefix check to ensure file integrity.
- Show download progress bar (disable with progress=False).
- Support network timeout and retry mechanism for stability.
- Automatically create parent directories for the destination path.
Args
- url (
str): URL address to download (supports HTTP/HTTPS). - dst (
str | Path): Destination path (including filename) to save the file. - hash_prefix (
Optional[str]): SHA256 hash prefix for integrity check, default None. - progress (
bool): Whether to show download progress bar, default True. - timeout (
float): Network request timeout in seconds, default 10.0. - max_retries (
int): Maximum number of retry attempts for network errors, default 3. - overwrite (
bool): Whether to overwrite existing file, default False. - allow_resume (
bool): Whether to support resuming interrupted downloads, default True. - user_agent (
str): Custom User-Agent header for HTTP requests, default USER_AGENT.
get_dir() [source]
python
get_dir() -> pathlib._local.PathGet the TensorPlay Hub cache directory used for storing downloaded models & weights.
set_dir() [source]
python
set_dir(d: Union[str, pathlib._local.Path]) -> NoneOptionally set the TensorPlay Hub directory used to save downloaded models & weights.
Args
- d (
str): path to a local folder to save downloaded models & weights.
