# 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)
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

### 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)
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.

#### Methods

##### init

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

##### log_summary

```python
def log_summary(self):
```

Warn about populated data the downgrade discarded.

#### Attributes

##### target_version

LDF version the records are rewritten to.

## Functions

### resolve_export_version

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

Resolve and validate a requested native export version.

Parameters

 * `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).

Returns

 * `Version`: The resolved version.

Raises

 * `ValueError`: If the version is malformed, is newer than this installation writes, or is not one the native exporter can
   produce.

## Attributes

### SUPPORTED_EXPORT_VERSIONS

LDF versions the native exporter can write, newest first.
