API Reference¶
Dataset discovery¶
Dataset access¶
- tsdb.load(dataset_name: str, use_cache: bool = True, *, cache_dir: str | PathLike | None = None) dict[source]¶
Load a dataset; cache_dir temporarily overrides the resolved cache.
use_cache=False stages and validates a fresh replacement.
- tsdb.download_and_extract(dataset_name: str, dataset_saving_path: str) None[source]¶
Download a registered dataset’s raw files into a new directory.
All required sources must succeed before publication. An existing destination is never overwritten by this function.
- tsdb.download_url(url: str, saving_path: str) str[source]¶
Download a CSV/TXT or supported archive into a new destination directory.
The destination must not exist. Failed or interrupted downloads leave no partial destination. Return the directory (or decompressed .txt/.csv path for a single gzip file). TLS verification is not disabled.
Cache management¶
- tsdb.get_cache_dir(*, cache_dir: str | PathLike | None = None) str[source]¶
Return the effective absolute cache directory (explicit, env, config, default).
- tsdb.list_cache(*, cache_dir: str | PathLike | None = None) list[source]¶
List registered cached datasets in the resolved or explicitly supplied cache.
- tsdb.delete_cache(dataset_name: str | None = None, only_pickle: bool = False, *, cache_dir: str | PathLike | None = None) None[source]¶
Delete registered dataset directories, or only their TSDB-owned parsed cache files.
- tsdb.migrate_cache(target_path: str) None[source]¶
Migrate the configured cache and switch paths after successful copying.
tsdb.CACHED_DATASET_DIR resolves the current configured cache directory on
access. Unlike discovery APIs, reading it can initialize configuration and
perform legacy cache migration.
File utilities¶
- tsdb.migrate(old_path: str, new_path: str, symlink: bool = False) None[source]¶
Safely migrate to a new or empty directory; refuse overlaps and conflicts.
If publication or configuration fails, retain the source. A complete destination copy may remain for manual recovery. Do not run with external writers changing either tree.
- tsdb.pickle_dump(data: object, path: str) None[source]¶
Atomically write a trusted local pickle; preserve an earlier file on failure.
- tsdb.pickle_load(path: str) object[source]¶
Read a trusted local pickle. Never load a pickle from an untrusted source.
- tsdb.purge_path(path: str, ignore_errors: bool = True) None[source]¶
Delete the given path. It will be deleted if a file is given. Itself and all its contents will be purged will a fold is given.
- Parameters:
path – It could be a file or a fold.
ignore_errors – Errors are ignored if ignore_errors is set.