# ldf_downgrade

Python API: `luxonis_ml.data.exporters.ldf_downgrade`

Rewriting exported native records to older LDF versions.

[DatasetRecord](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/ldf/annotation.md#annotation-Classes-DatasetRecord)
forbids extra fields, so a record written by a newer luxonis-ml fails to validate on an older install -- LDF 2.1 added
`sample_metadata`, which nothing older accepts. Exporting to an older version therefore drops every field introduced above it.

## Classes

| Name | Description |
| --- | --- |
| [`LDFDowngrader`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/exporters/ldf_downgrade.md#ldf_downgrade-Classes-LDFDowngrader) | Strips exported native records down to an older LDF version. |

### class `LDFDowngrader`

```python
class LDFDowngrader
```

Strips exported native records down to an older LDF version.

Records are built at the current
[LDF_VERSION](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/utils/constants.md#constants-Module-Attributes-LDF_VERSION)
and passed through a downgrader on their way out, which keeps version-specific knowledge in one place and lets discarded data be
counted as it goes.

Attributes

| Name | Description |
| --- | --- |
| `target_version` | LDF version the records are rewritten to. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/exporters/ldf_downgrade.md#ldf_downgrade-Classes-LDFDowngrader-__init__) | Create a downgrader for one target version. |
| [`log_summary`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/exporters/ldf_downgrade.md#ldf_downgrade-Classes-LDFDowngrader-log_summary) | Warn about populated data the downgrade discarded. |

#### method `__init__`

```python
def __init__(target_version: Version)
```

Create a downgrader for one target version.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `target_version` | `Version` | LDF version to write. Fields that a newer version added are dropped from each record. | required |

#### method `log_summary`

```python
def log_summary()
```

Warn about populated data the downgrade discarded.

## Functions

| Name | Description |
| --- | --- |
| [`resolve_export_version`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/exporters/ldf_downgrade.md#ldf_downgrade-Functions-resolve_export_version) | Resolve and validate a requested native export version. |

### function `resolve_export_version`

```python
def resolve_export_version(version: str | Version | None) -> Version
```

Resolve and validate a requested native export version.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `version` | `str | Version | None` | Requested LDF version. Minor and patch parts are optional, so both `"2.0"` and `"2.0.0"` are accepted. `None` selects the current [LDF_VERSION](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/utils/constants.md#constants-Module-Attributes-LDF_VERSION). | required |

Returns

| Type | Description |
| --- | --- |
| `Version` | The resolved version. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the version is malformed, is newer than this installation writes, or is not one the native exporter can produce. |

## Module Attributes

| Name | Type | Description |
| --- | --- | --- |
| [`SUPPORTED_EXPORT_VERSIONS`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/exporters/ldf_downgrade.md#ldf_downgrade-Module-Attributes-SUPPORTED_EXPORT_VERSIONS) | `tuple[Version, ...]` | LDF versions the native exporter can write, newest first. |

### constant `SUPPORTED_EXPORT_VERSIONS`

```python
SUPPORTED_EXPORT_VERSIONS: tuple[Version, ...] = (LDF_VERSION, _parse('2.0'))
```

LDF versions the native exporter can write, newest first.
