Skip to content

Api

timenet_connectors.api source

Producer-side shortcuts to build and load a dataset from local code.

:func:build runs a connector through the engine into the shared local registry. :func:load runs build and reads the result back. The writer and reader stacks are heavy, so they load lazily. This keeps the import of :mod:timenet_connectors cheap.

build source

build(
    dataset_id: str,
    *,
    version: str | None = None,
    out: str | Path | None = None,
    force: bool = False,
    keep_cache: bool = False,
) -> Path

Build a dataset into a local registry by connector id.

This is the producer-side one-liner over the engine. The build reuses an already-built version unless the caller sets force. The default output is the shared local registry (:func:timenet.registry.default_registry_path). The SDK reads from that directory, so a build here loads at once with TimeNet().load(dataset_id).

Like timenet-build build, this runs the connector in an environment built from its requirements.txt. Set TIMENET_ISOLATION=off to run it in this interpreter instead, which is what you want while writing a connector.

Parameters:

Name Type Description Default
dataset_id str

The dataset id (org/name).

required
version str | None

The expected dataset version. A connector produces only its own version, so this value is a guard. If it does not match the connector's metadata, the build stops before it runs. None builds the version that the connector declares.

None
out str | Path | None

Output registry directory. Defaults to the shared local registry.

None
force bool

Rebuild even if the registry already has a built version.

False
keep_cache bool

Keep the raw download cache. A successful build deletes it by default.

False

Returns:

Type Description
Path

The committed version directory.

Raises:

Type Description
TimeFValidationError

If the caller sets version and it does not match the connector's declared version.

load source

load(
    dataset_id: str, version: str | None = None
) -> TimeFDataset

Build a dataset if needed, then load it into memory.

This is the one-call sugar over :func:build plus :meth:timenet.client.TimeNet.load. For a clear producer and consumer split, call :func:build and TimeNet().load yourself.

Parameters:

Name Type Description Default
dataset_id str

The dataset id (org/name).

required
version str | None

The version string, or None for the latest. :func:build checks this value against the connector's declared version and rejects a mismatch.

None

Returns:

Type Description
TimeFDataset

The loaded dataset.