# helia_edge.export.reproduce

Reproduce an export from its record (``helia-edge export reproduce``) and create one from a spec file.

## helia_edge.export.reproduce.Reproduction

`class` · `python`

```python
Reproduction(
    status: Literal['same', 'different', 'environment', 'input'],
    differences: tuple[str, ...] = (),
    environment: tuple[str, ...] = (),
    skipped: tuple[str, ...] = (),
) -> None
```

`dataclass`

What ``reproduce`` found.

Source: `helia_edge/export/reproduce.py:14`

### helia_edge.export.reproduce.Reproduction.status

`attribute` · `python`

```python
status: Literal['same', 'different', 'environment', 'input']
```

``same`` (same artifact, I/O and golden), ``different``, ``environment`` (the environment
differs and the comparison was not made) or ``input`` (a file is missing or does not match the
record).

Source: `helia_edge/export/reproduce.py:27`

### helia_edge.export.reproduce.Reproduction.differences

`attribute` · `python`

```python
differences: tuple[str, ...] = ()
```

What differs, or which input is missing or does not match, one line each.

Source: `helia_edge/export/reproduce.py:28`

### helia_edge.export.reproduce.Reproduction.environment

`attribute` · `python`

```python
environment: tuple[str, ...] = ()
```

How the environment differs from the record's, or why it cannot export, one line each.

Source: `helia_edge/export/reproduce.py:29`

### helia_edge.export.reproduce.Reproduction.skipped

`attribute` · `python`

```python
skipped: tuple[str, ...] = ()
```

What the record names but was not compared, one line each.

Source: `helia_edge/export/reproduce.py:30`

## helia_edge.export.reproduce.file_sha256

`function` · `python`

```python
file_sha256(path: Path | str) -> str
```

sha256 of a file's bytes.

Source: `helia_edge/export/reproduce.py:33`

## helia_edge.export.reproduce.load_npy

`function` · `python`

```python
load_npy(path: Path | str) -> np.ndarray
```

A ``.npy`` array, memory-mapped, so that a header claiming more data than the file holds is refused
rather than allocated.

**Raises**

| Name | Description |
| --- | --- |
| ValueError | If the file cannot be read as a ``.npy`` array. |

Source: `helia_edge/export/reproduce.py:42`

## helia_edge.export.reproduce.load_spec

`function` · `python`

```python
load_spec(path: Path | str)
```

A ``ModelSpec`` from a YAML (``.yaml``/``.yml``) or JSON file.

**Raises**

| Name | Description |
| --- | --- |
| ValueError | If the file is not valid YAML or JSON, or not a valid ``ModelSpec``. |

Source: `helia_edge/export/reproduce.py:59`

## helia_edge.export.reproduce.family_mapping

`function` · `python`

```python
family_mapping(spec, name: str)
```

The weight mapping ``name`` of the spec's family (its params module's ``MAPPINGS``).

Source: `helia_edge/export/reproduce.py:79`

## helia_edge.export.reproduce.environment_differences

`function` · `python`

```python
environment_differences(recorded: EnvironmentEntry, current: EnvironmentEntry) -> list[str]
```

How ``current`` differs from ``recorded``, in the versions that can change exported bytes.

Source: `helia_edge/export/reproduce.py:87`

## helia_edge.export.reproduce.litert_unavailable

`function` · `python`

```python
litert_unavailable() -> tuple[str, ...]
```

Why this process cannot export LiteRT, one line each; empty when it can.

Source: `helia_edge/export/reproduce.py:116`

## helia_edge.export.reproduce.reproduce

`function` · `python`

```python
reproduce(
    record_path: Path | str,
    weights: Path | str,
    calibration: Path | str | None = None,
    golden_inputs: Path | str | None = None,
    allow_env_mismatch: bool = False,
) -> Reproduction
```

Rebuild the model a record describes, export it again with the same settings and compare.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| record_path | Path \| str | Required | The ``record.json``. |
| weights | Path \| str | Required | The ``.weights.h5`` file, or for imported weights the source file the mapping imports. |
| calibration | Path \| str \| None | None | The calibration ``.npy``, when the record has calibration. |
| golden_inputs | Path \| str \| None | None | The golden's input ``.npy``, to regenerate and compare the golden. |
| allow_env_mismatch | bool | False | Compare even when the environment differs from the record's. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
| Reproduction | Reproduction | ``same`` when the weights digest, the export settings, the artifact, the I/O, the golden |
|  | Reproduction | (with ``golden_inputs``) and the ``model.tflite`` and ``golden.npz`` beside the record (when present) |
|  | Reproduction | match. A failure of the export itself is raised. |

Source: `helia_edge/export/reproduce.py:141`

## helia_edge.export.reproduce.imported_source

`function` · `python`

```python
imported_source(mapping, sha256: str) -> WeightImport
```

The record of weights imported through ``mapping`` from a file with ``sha256``.

Source: `helia_edge/export/reproduce.py:241`
