# Timenet.provenance

## timenet.provenance

Read the git commit of the installed TimeNet code, for the manifest's `build_env.git` block.

### EditableInstall `dataclass`

Bases: `InstallSource`

An editable install (`pip install -e`, or a uv workspace member).

Python imports the code from the checkout itself, so git reports its commit and local changes.

#### package\_name `instance-attribute`

```
package_name: PackageName
```

#### project\_directory `instance-attribute`

```
project_directory: Path
```

#### read\_git\_source

```
read_git_source() -> GitSource
```

Ask git for the commit of the checkout and whether the package directory has changes.

### GitInstall `dataclass`

Bases: `InstallSource`

An install from a git URL (`pip install git+https://...`). Pip recorded the commit.

#### commit\_id `instance-attribute`

```
commit_id: str
```

#### package\_name `instance-attribute`

```
package_name: PackageName
```

#### read\_git\_source

```
read_git_source() -> GitSource
```

Return the commit that pip installed, which has no local changes.

### InstallSource `dataclass`

Bases: `ABC`

Where one package was installed from: a git checkout, a git URL, or a wheel.

Each kind records its git provenance in a different place.

#### package\_name `instance-attribute`

```
package_name: PackageName
```

#### read\_git\_source `abstractmethod`

```
read_git_source() -> GitSource
```

Return the commit of the code that this install runs. Raises `TimeNetBuildError` if it is unknown.

### InstalledDistribution

One distribution that is installed in this interpreter.

#### name `property`

```
name: PackageName
```

The package name that pip installs, for example `timenet-connectors`.

#### version `property`

```
version: str
```

The installed version.

#### from\_name `classmethod`

```
from_name(name: PackageName) -> Self
```

Find an installed package by name, such as `timenet`.

Note: An extra like `timenet[zarr]` is not a name, and `from_name` would not find it.

Returns:

| Type | Description |
| --- | --- |
| `Self` | The installed package. |

Raises:

| Type | Description |
| --- | --- |
| `PackageNotFoundError` | If it is not installed. |

#### install\_source

```
install_source() -> InstallSource
```

Return how this distribution was installed, which decides where its commit is recorded.

#### path\_to\_ondisk\_project\_directory

```
path_to_ondisk_project_directory() -> Path | None
```

Return the project directory of an editable or local path install, else `None`.

#### read\_git\_source

```
read_git_source() -> GitSource
```

Return the commit of the code that this distribution runs. Raises `TimeNetBuildError` if it is unknown.

### PackageSnapshot

Bases: `Snapshot`

The commit of one package that pip installed, such as `timenet` or `timenet-connectors`.

Note: Not a subpackage such as `timenet.registry`.

#### model\_config `class-attribute` `instance-attribute`

```
model_config = ConfigDict(
    frozen=True, validate_by_name=True
)
```

#### package\_name `instance-attribute`

```
package_name: PackageName
```

The name pip installs, for example `timenet-connectors`.

#### source `instance-attribute`

```
source: GitSource
```

#### read `classmethod`

```
read(package_name: PackageName) -> Self
```

Read the commit of an installed package. Raises `TimeNetBuildError` if it is not installed.

#### read\_if\_installed `classmethod`

```
read_if_installed(package_name: PackageName) -> Self | None
```

Read the commit of a package, or return `None` if it is not installed.

#### to\_source\_map

```
to_source_map() -> GitSourceMap
```

Return this package's commit in the form that a manifest records.

### Snapshot

Bases: `BaseModel`, `ABC`

The commit of some installed code, read at one point in time.

#### model\_config `class-attribute` `instance-attribute`

```
model_config = ConfigDict(
    frozen=True, validate_by_name=True
)
```

#### to\_source\_map `abstractmethod`

```
to_source_map() -> GitSourceMap
```

Return the commits in the form that a manifest records.

### TimeNetSnapshot

Bases: `Snapshot`

The commit of each installed TimeNet package, read at one point in time.

#### model\_config `class-attribute` `instance-attribute`

```
model_config = ConfigDict(
    frozen=True, validate_by_name=True
)
```

#### timenet `instance-attribute`

```
timenet: PackageSnapshot
```

#### timenet\_connectors `class-attribute` `instance-attribute`

```
timenet_connectors: PackageSnapshot | None = Field(
    default=None, alias="timenet-connectors"
)
```

`None` if timenet-connectors is not installed.

#### from\_source\_map `classmethod`

```
from_source_map(sources: GitSourceMap) -> Self
```

Return the typed view of the commits that a manifest records.

#### package\_names `classmethod`

```
package_names() -> tuple[PackageName, ...]
```

Return the name of each TimeNet package, in field order.

#### packages\_with\_local\_changes

```
packages_with_local_changes() -> list[PackageSnapshot]
```

Return each installed TimeNet package whose code has local changes.

#### read `classmethod`

```
read() -> Self
```

Read the commit of each installed TimeNet package. Raises `TimeNetBuildError` if one is unknown.

#### to\_source\_map

```
to_source_map() -> GitSourceMap
```

Return the commit of each installed TimeNet package.

### WheelInstall `dataclass`

Bases: `InstallSource`

An install from a wheel, including a path install that is not editable (pip builds a wheel first).

The installed code is a copy, so a checkout can differ from it. The wheel carries the git
provenance record baked into it at build time (`_build_info.json`).

#### BUILD\_INFO\_FILE `class-attribute`

```
BUILD_INFO_FILE: str = '_build_info.json'
```

The commit record in each wheel. `scripts/build_dists.py` writes it.

#### build\_info `instance-attribute`

```
build_info: Path
```

#### package\_name `instance-attribute`

```
package_name: PackageName
```

#### read\_git\_source

```
read_git_source() -> GitSource
```

Read the commit that `scripts/build_dists.py` wrote into the package.
