API Reference

Dataset discovery

tsdb.list() → list[source]

Return the registered dataset names without importing data loaders.

tsdb.info(name: str) → dict[source]

Return dataset metadata without downloading, parsing or touching caches.

Unknown source license, task or revision metadata is represented by None. The dataset profile links to the maintained source/citation information.

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.

exception tsdb.utils.file.CacheError[source]

A trusted local cache could not be read or written.

Shared logging

class tsdb.utils.logging.Logger(name: str = 'TSDB running log', logging_level: str = 'debug', logging_format: str = '%(asctime)s [%(levelname)s]: %(message)s')[source]

Configure a named logger with one TSDB-owned stream and optional file handler.

Instances with the same name share handler configuration. The most recent constructor or configuration call sets the level and format for that name. Application-owned handlers are not removed or reconfigured.

property stream_handler

The current TSDB-owned console handler for this logger name.

property file_handler

The current TSDB-owned file handler, or None if not configured.

property logging_level

Current numeric level shared by wrappers of this logger.

property formatter

Current console formatter shared by wrappers of this logger.

set_logging_format(logging_format: str) → None[source]

Set the format for the shared TSDB-owned handlers.

set_saving_path(saving_dir: str, name: str, mode: str = 'a') → None[source]

Enable UTF-8 file logging, replacing the previous TSDB-owned file handler.

Parameters:
  • saving_dir – The directory for logging file saving.

  • name – The name of the logging file.

  • mode – Logging file writing mode.

set_level(level: str) → None[source]

Set the shared logging level (debug/info/warning/error).

tsdb.utils.logging.logger is the shared standard-library logger.

See Usage for examples and Migrating from TSDB 0.8 to v1.0 for changed error behavior.