# luxonis_parser

Python API: `luxonis_ml.data.parsers.luxonis_parser`

## Classes

| Name | Description |
| --- | --- |
|
[`LuxonisParser`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/luxonis_parser.md)
| Detect a dataset format and dispatch to the matching parser. |
|
[`ParserType`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/luxonis_parser.md)
| Recognized parser entry-point type. |

### class `LuxonisParser`

```python
class LuxonisParser(Generic)
```

Detect a dataset format and dispatch to the matching parser.

The parser accepts local paths, remote paths supported by
[LuxonisFileSystem](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/utils/filesystem.md),
ZIP archives, and Roboflow dataset URLs in `roboflow://workspace/project/version/format` form. If `dataset_type` is omitted,
parsers are tried until one validates the dataset directory as either a full directory or a single split.

Methods

| Name | Description |
| --- | --- |
|
[`__init__`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/luxonis_parser.md)
| High-level abstraction over various parsers. |
|
[`get_parser_issue_messages`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/luxonis_parser.md)
| Return parser issue messages collected during the last parse. |
|
[`parse`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/luxonis_parser.md)
| Parse the dataset and return it in LDF format. |

#### method `__init__`

```python
def __init__(
    dataset_dir: str,
    *,
    dataset_name: str | None = None,
    save_dir: Path | str | None = None,
    dataset_plugin: T = None,
    dataset_type: DatasetType | None = None,
    task_name: str | dict[str, str] | None = None,
    full_warnings: bool = False,
    **kwargs,
)
```

High-level abstraction over various parsers.

Automatically recognizes the dataset format and uses the appropriate parser.

Args

 * `dataset_dir` (`str`): Dataset directory identifier. Can be one of: * Local path to the dataset directory.
    * * `Remote URL supported by L{LuxonisFileSystem}.`: * `gcs://` or `gs://` for Google Cloud Storage
          * `s3://` for Amazon S3
    * * `roboflow://` for Roboflow datasets.`: * Expected format: `roboflow://workspace/project/version/format`.
    * * `ultralytics://` for Ultralytics Platform datasets.`: * Expected format: `ultralytics://username/datasets/slug`
          * Optional version: append `?v=<version>` to export a specific dataset version.
 * `dataset_name` (`str | None`): Optional output dataset name. If omitted, the name is derived from `dataset_dir`.
 * `save_dir` (`Path | str | None`): Optional directory used when downloading remote datasets. If omitted, the current working
   directory is used.
 * `dataset_plugin` (`T`): Optional dataset plugin registry name. If omitted, `LuxonisDataset` is used.
 * `dataset_type` (`DatasetType | None`): Optional dataset type. If provided, automatic format recognition is skipped.
 * `task_name` (`str | dict[str, str] | None`): Optional task naming rule. A string is used for all records. A mapping uses class
   names as keys and task names as values.
 * `full_warnings` (`bool`): Whether all skipped annotation warnings should be logged without truncation.
 * `**kwargs`: Additional arguments passed to the selected dataset constructor.

Raises

| Type | Description |
| --- | --- |
| `RuntimeError` | If a Roboflow URL is used and `ROBOFLOW_API_KEY` is not configured. |
| `ValueError` | If a Roboflow URL is malformed, its version is not an integer, or the dataset format cannot be recognized. |

#### method `get_parser_issue_messages`

```python
def get_parser_issue_messages() -> list[ParserIssueMessage]
```

Return parser issue messages collected during the last parse.

#### method `parse`

```python
def parse(**kwargs) -> BaseDataset
```

Parse the dataset and return it in LDF format.

If the dataset already exists, parsing will be skipped and the existing dataset will be returned instead.

> **Note**
> When the parser reads a single split, this method sets `random_split=True` unless you pass your own value. This differs from [BaseParser.parse_split](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/base_parser.md), which declares `random_split=False`. A single split therefore gets random train, val, and test splits by default.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `**kwargs` |  | Parser-specific arguments. |  |

Returns

| Type | Description |
| --- | --- |
| `BaseDataset` | Parsed dataset. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the selected parser rejects the dataset structure or split arguments. |

### class `ParserType`

```python
class ParserType(Enum)
```

Recognized parser entry-point type.

Attributes

| Name | Type | Description |
| --- | --- | --- |
| `DIR` | `str` | Dataset directory with multiple splits. |
| `SPLIT` | `str` | Directory or file representing one parser input split. |

## Module Attributes

| Name | Description |
| --- | --- |
|
[`T`](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/data/parsers/luxonis_parser.md)
| |

### type variable `T`

```python
T = TypeVar('T', str, None)
```
