Client
timenet.client ¶source
The :class:TimeNet class is the SDK's single entry point for using TimeNet from code.
This class wraps a :class:~timenet.registry.BaseRegistry (the catalog) and a local storage path
(the download cache). It exposes these methods: list, get, search, download,
open, load, and open_torch. Against a local registry, open and load build a
dataset the registry does not have when an installed package registers a connector for its id;
against a remote registry they never run connector code.
TimeNet ¶source
Browse a registry and fetch datasets to local storage.
download ¶source
download(
dataset_id: str,
version: str | None = None,
*,
force: bool = False,
progress_cb: ProgressCallback | None = None,
) -> Path
Fetch a version and each of its payload sources into local storage.
Build-only parents remain recorded in the manifest and are not downloaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset id. |
required |
version
|
str | None
|
The version string, or |
None
|
force
|
bool
|
Download again, even if an up-to-date copy already exists. |
False
|
progress_cb
|
ProgressCallback | None
|
Called with each file's byte count as it lands, for a progress display. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The local |
list ¶source
Return the metadata of every dataset in the registry.
Returns:
| Name | Type | Description |
|---|---|---|
One |
_Metadatas
|
class: |
load ¶source
load(
dataset_id: str,
version: str | None = None,
*,
auto_build: bool = True,
fetch_from: str | BaseRegistry | None = None,
) -> TimeFDataset
Read a whole dataset version into memory, with every stored value loaded.
The dataset needs no storage afterwards: its reader is closed before it is returned. For a
large dataset, use :meth:open and read what you need instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset id. |
required |
version
|
str | None
|
The version string, or |
None
|
auto_build
|
bool
|
Build a missing local release from its connector. Set false to raise instead. |
True
|
fetch_from
|
str | BaseRegistry | None
|
The registry, or its URI, to copy missing local releases from. |
None
|
Returns:
| Type | Description |
|---|---|
TimeFDataset
|
The dataset with every signal array, time offset, and text value loaded. |
Raises:
| Type | Description |
|---|---|
TimeNetAccessError
|
If the dataset is not open access and the registry is not local.
Also if the call must copy a release without access declared |
TimeNetDatasetNotFoundError
|
If the version is absent and nothing builds it, or the connector declares a different version than the one asked for. |
TimeNetInvalidCardError
|
If the card of the connector cannot be read. |
TimeNetMissingParentError
|
If a release that the version or its build needs is absent and the call cannot obtain it. |
TimeNetFileError
|
If a local copy is damaged and |
TimeFFormatError
|
If the build of a payload source does not reproduce the pinned files. |
TimeNetBuildError
|
If the build runs but fails. |
TimeFValidationError
|
If a remote client gets |
open ¶source
open(
dataset_id: str,
version: str | None = None,
*,
auto_build: bool = True,
fetch_from: str | BaseRegistry | None = None,
) -> TimeFReader
Prepare a dataset version and its payload sources, then open it for lazy reads.
Opening reads the version's manifest, but neither its catalog nor any value. The reader's reads leave stored values behind value handles unless their load plan names them. Close the reader after use, or use it as a context manager. Remote backends open payload sources from their manifests upfront and read payload ranges on demand, reusing complete cached releases.
Against a local registry, the call needs the version and its payload sources. If the call
builds the version, the build also needs the declared parents of the version and their
payload sources. For each of these releases, the call uses the first step that works. It
reuses a complete local copy, or copies the release from fetch_from, or builds the
release from its installed connector. The call builds only if auto_build is set. If no
step works, the call raises an error.
The call builds a payload source with its own connector, at the exact version of the source. The build gets the pins of the version. The build runs in staging. It publishes the source only if it reproduces the pinned files.
A local copy is damaged if its manifest is present but a file is missing or has another
size. If fetch_from is set, the call repairs a damaged copy from that registry. The call
never builds a release over a damaged copy. Against a remote registry, open never runs
connector code. If a remote client gets fetch_from, open raises an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset id. |
required |
version
|
str | None
|
The version string, or |
None
|
auto_build
|
bool
|
Build a missing local release from its connector. Set false to raise instead. |
True
|
fetch_from
|
str | BaseRegistry | None
|
The registry, or its URI, to copy missing local releases from. |
None
|
Returns:
| Type | Description |
|---|---|
TimeFReader
|
A reader for the version. |
Raises:
| Type | Description |
|---|---|
TimeNetAccessError
|
If the dataset is not open access and the registry is not local.
Also if the call must copy a release without access declared |
TimeNetDatasetNotFoundError
|
If the version is absent and nothing builds it, or the connector declares a different version than the one asked for. |
TimeNetInvalidCardError
|
If the card of the connector cannot be read. |
TimeNetMissingParentError
|
If a release that the version or its build needs is absent and the call cannot obtain it. The message names the keyword that can obtain it. |
TimeNetFileError
|
If a local copy is damaged and |
TimeFFormatError
|
If the build of a payload source does not reproduce the pinned files. |
TimeNetBuildError
|
If the build runs but fails. |
TimeFValidationError
|
If a remote client gets |
open_torch ¶source
open_torch(
dataset_id: str,
version: str | None = None,
*,
auto_build: bool = True,
fetch_from: str | BaseRegistry | None = None,
load: LoadPlan = ALL_EAGER,
) -> TimeFTorchDataset
Open a dataset version as a read-only PyTorch Dataset that reads it a batch at a time.
The view holds an open reader from :meth:open. Close the view with its close()
method, or use it in a with block. This method needs the torch extra
(pip install 'timenet[torch]'). The code imports the torch view lazily, so base users do
not need torch installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
The dataset id. |
required |
version
|
str | None
|
The version string, or |
None
|
auto_build
|
bool
|
Build a missing local release from its connector. Set false to raise instead. |
True
|
fetch_from
|
str | BaseRegistry | None
|
The registry, or its URI, to copy missing local releases from. |
None
|
load
|
LoadPlan
|
The plan that each batch loads with. A text-only plan, for example, skips the arrays of candidate and target Records. |
ALL_EAGER
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
TimeFTorchDataset
|
class: |
TimeFTorchDataset
|
and loads one batch of records at a time. |
search ¶source
search(
*,
query: _OrList[str] = None,
domain: _OrList[Domain] = None,
task: _OrList[type[Task]] = None,
license: _OrList[License] = None,
time_series_spec: _OrList[str] = None,
dataset_id: _OrList[str] = None,
tag: _OrList[str] = None,
limit: int = 100,
) -> _Metadatas
Search the registry. This method mirrors :meth:~timenet.registry.BaseRegistry.search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
_OrList[str]
|
Free text terms for the name, description, and tags. |
None
|
domain
|
_OrList[Domain]
|
Keep datasets that share any of these domains. |
None
|
task
|
_OrList[type[Task]]
|
Keep datasets whose schema includes any of these task classes. |
None
|
license
|
_OrList[License]
|
Keep datasets with any of these licenses. |
None
|
time_series_spec
|
_OrList[str]
|
Keep datasets that declare all of these |
None
|
dataset_id
|
_OrList[str]
|
Keep only these ids. |
None
|
tag
|
_OrList[str]
|
Keep datasets that declare all of these tags. |
None
|
limit
|
int
|
The maximum number of results. |
100
|
Returns:
| Type | Description |
|---|---|
_Metadatas
|
The matching dataset metadata. |