# Package eido Documentation

## Package Overview

The `eido` package provides validation and filtering tools for PEPs (Portable Encapsulated Projects). It enables schema-based validation of project metadata and provides flexible filtering mechanisms.

### Key Features

- **Schema Validation**: Validate PEPs against JSON schemas
- **Sample Filtering**: Filter samples based on custom criteria
- **Config Validation**: Validate project configuration separately
- **Extensible Filtering**: Support for custom filter plugins
- **Error Reporting**: Detailed validation error messages

### Installation

```bash
pip install eido
```

### Quick Example

```python
from eido import validate_project
from peppy import Project

# Load a project
prj = Project("project_config.yaml")

# Validate against a schema
validate_project(prj, "schema.yaml")
```

## API Reference

### Validation Functions

<a id="eido.validate_project"></a>

### `validate_project`

```python
def validate_project(project: peppy.Project, schema: Union[str, dict]) -> None
```

Validate a project object against a schema

:param peppy.Project project: a project object to validate
:param str | dict schema: schema dict to validate against or a path to one
from the error. Useful when used ith large projects

:return: None
:raises EidoValidationError: if validation is unsuccessful

<a id="eido.validate_sample"></a>

### `validate_sample`

```python
def validate_sample(project: peppy.Project, sample_name: Union[str, int], schema: Union[str, dict]) -> None
```

Validate the selected sample object against a schema

:param peppy.Project project: a project object to validate
:param str | int sample_name: name or index of the sample to validate
:param str | dict schema: schema dict to validate against or a path to one

:raises EidoValidationError: if validation is unsuccessful

<a id="eido.validate_config"></a>

### `validate_config`

```python
def validate_config(project: Union[peppy.Project, dict], schema: Union[str, dict]) -> None
```

Validate the config part of the Project object against a schema

:param peppy.Project project: a project object to validate
:param str | dict schema: schema dict to validate against or a path to one

### Schema Functions

<a id="eido.read_schema"></a>

### `read_schema`

```python
def read_schema(schema)
```

Safely read schema from YAML-formatted file.

If the schema imports any other schemas, they will be read recursively.

:param str | Mapping schema: path to the schema file
    or schema in a dict form
:return list[dict]: read schemas
:raise TypeError: if the schema arg is neither a Mapping nor a file path or
    if the 'imports' sections in any of the schemas is not a list

### Exceptions

<a id="eido.EidoValidationError"></a>

### `EidoValidationError`

```python
class EidoValidationError(message, errors_by_type)
```

Bases: `EidoException`

Object was not validated successfully according to schema.

#### Attributes

- <a id="eido.EidoValidationError.errors_by_type"></a>**`errors_by_type`**
- <a id="eido.EidoValidationError.message"></a>**`message`**
