# Timenet.producer

## timenet.producer

Build dataset releases in a local registry and publish them to other registries.

The default local and remote registries come from `TIMENET_LOCAL_REGISTRY` and `TIMENET_REMOTE_REGISTRY`.
`TIMENET_AUTO_BUILD` controls whether installed connectors supply missing parents by default.

### build

```
build(
    dataset_id: str,
    *,
    local_registry: str
    | Path
    | LocalRegistry
    | None = None,
    sources: Sequence[ReleaseSource | str | Path]
    | None = None,
    force: bool = False,
    open_access_only: bool = False,
    keep_cache: bool = False,
    progress: ProgressCallback | None = None,
) -> Path
```

Build a dataset release into a local registry with its installed connector.

Missing parents and payload sources come from the first source in `sources` that provides them.
The build uses a separate environment with the connector's dependencies unless `TIMENET_ISOLATION` is `off`.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `dataset_id` | `str` | The dataset ID (`org/name`) or exact release (`org/name@1.2.0`). | *required* |
| `local_registry` | `str | Path | LocalRegistry | None` | The writable local registry to build into: a `LocalRegistry`, a local path, or a `file://` URI, or `None` for `TIMENET_LOCAL_REGISTRY`. | `None` |
| `sources` | `Sequence[ReleaseSource | str | Path] | None` | Sources, registry URLs, or paths for missing releases, or `None` for :func:`~timenet.client.default_sources` with `local_registry` first. | `None` |
| `force` | `bool` | Build the release again, even if the local registry holds it. | `False` |
| `open_access_only` | `bool` | Require open access for every release before running the plan. | `False` |
| `keep_cache` | `bool` | Keep the raw downloads in `TIMENET_CACHE` after the build. | `False` |
| `progress` | `ProgressCallback | None` | A callback for copy and build progress events. | `None` |

Returns:

| Type | Description |
| --- | --- |
| `Path` | The release directory in the local registry. |

Raises:

| Type | Description |
| --- | --- |
| `TimeFValidationError` | If `local_registry` is not a writable local registry, or `sources` is invalid. |
| `TimeNetRegistryError` | If a registry in `sources` fails to open. |
| `TimeNetDatasetNotFoundError` | If no installed connector builds the dataset. |
| `TimeNetVersionUnavailableError` | If the requested version differs from the connector's version. |
| `TimeNetMissingParentError` | If no source provides a required parent or payload source. |
| `TimeNetAccessError` | If no source grants access to a parent or a release violates `open_access_only`. |
| `TimeNetVersionConflictError` | If a release to copy has other files than the same version in the local registry. |
| `TimeNetFileError` | If a stored release is damaged and no registry in `sources` provides it. |
| `TimeNetBuildError` | If a build fails. |

### publish

```
publish(
    dataset_id: str | DatasetRef,
    *,
    dest: str | Path | WritableRegistry,
    source: str | Path | BaseRegistry | None = None,
    progress: ProgressCallback | None = None,
) -> DatasetRef
```

Copy a release and its required payload sources to another registry.

The copy skips identical releases and rejects conflicting files before writing to `dest`.
It replaces missing or damaged files at a local destination.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `dataset_id` | `str | DatasetRef` | `org/name` for the latest version in `source`, `org/name@1.2.0` for an exact release, or a `DatasetRef`, which needs no lookup in `source`. | *required* |
| `dest` | `str | Path | WritableRegistry` | The registry to copy to, or its URL or path. | *required* |
| `source` | `str | Path | BaseRegistry | None` | The source registry, URL, or path, or `None` for `TIMENET_LOCAL_REGISTRY`. | `None` |
| `progress` | `ProgressCallback | None` | A callback for copy progress events. | `None` |

Returns:

| Type | Description |
| --- | --- |
| `DatasetRef` | The ID and version of the release in `dest`. |

Raises:

| Type | Description |
| --- | --- |
| `TimeNetRegistryError` | If `dest` or `source` fails to open as a registry, or `dest` is read-only. |
| `TimeNetDatasetNotFoundError` | If `source` lacks the release. |
| `TimeNetAccessError` | If a registry withholds files or requires open access that a copied release lacks. |
| `TimeNetBuildError` | If `dest` is not local and a copied release records TimeNet code with local changes. |
| `TimeNetVersionConflictError` | If `dest` holds different files for the release or a required payload source. |
| `TimeNetMissingParentError` | If a required payload source is missing from `source` and incomplete in `dest`. |
