About the project
Xarrera is an open source project that provides an API for performing data-format validation on Xarray objects.
Getting Started
Prerequisites
- Python >= 3.9
Installation
Install Xarrera from PyPI:
pip install xarrera
Conda:
conda install -c conda-forge xarrera
Or install it from source:
pip install git+https://github.com/javgat/xarrera
Another option is cloning the repository and installing the python package and its dependencies by using:
git clone https://github.com/javgat/xarrera.git
cd xarrera
pip install -e .
Usage
Xarrera's API is modeled after Pandera. The DataArraySchema
and DatasetSchema objects both have .validate() methods.
The basic usage is as follows:
import numpy as np
import xarray as xr
from xarrera import DataArraySchema, DatasetSchema, CoordsSchema
da = xr.DataArray(np.ones(4, dtype='i4'), dims=['x'], name='foo')
schema = DataArraySchema(dtype=np.integer, name='foo', shape=(4, ), dims=['x'])
schema.validate(da)
You can also use it to validate a Dataset like so:
schema_ds = DatasetSchema({'foo': schema})
schema_ds.validate(da.to_dataset())
Each component of the Xarray data model is implemented as a stand alone class:
from xarrera.components import (
DTypeSchema,
DimsSchema,
ShapeSchema,
NameSchema,
ChunksSchema,
ArrayTypeSchema,
AttrSchema,
AttrsSchema
)
# example constructions
dtype_schema = DTypeSchema('i4')
dims_schema = DimsSchema(('x', 'y', None)) # None is used as a wildcard
shape_schema = ShapeSchema((5, 10, None)) # None is used as a wildcard
name_schema = NameSchema('foo')
chunk_schema = ChunksSchema({'x': None, 'y': -1}) # None is used as a wildcard, -1 is used as
ArrayTypeSchema = ArrayTypeSchema(np.ndarray)
# Example usage
dtype_schema.validate(da.dtype)
# Each object schema can be exported to JSON format
dtype_json = dtype_schema.to_json()
Roadmap
This is a very early prototype of a library, based on a library with multiple forks with small additions. The following key things to do are:
- Contact former
xarray-schemadevelopers, forkers, and issue writers aboutxarrera. - ...
- String comparison using regex xarray-schema~#9
- Accumulate schema exceptions and report them all at once.
Currently, we are a eagerly raising
SchemaErrorswhen the are found. - Improve SchemaError reported information.
- Extract schema from xarray objects xarray-schema~#45
Versioning
Version changes and descriptions are stored in the CHANGELOG. This file is updated each time a new version is released.
Contributing
Development Guide
-
Install npm (required for pre-commit hooks)
Some pre-commit hooks (e.g., for formatting or linting) depend on Node.js and npm. You can install them via your system package manager, or download from nodejs.org (npm is included).
For example, on Debian/Ubuntu:
sudo apt update sudo apt install nodejs npm
If you use conda, you can also install it with:
conda install -c conda-forge nodejs
-
Install Pre-commit Hooks
Install the
pre-commithooks to automatically check code styling:pre-commit install -
Install Python Dependencies
Install the python package dependencies listed in the
requirements.txtfile, preferably in a python virtual enironment:pip install -r requirements.txt # or pip install -e .
Testing
-
Install test dependencies
Install de development dependencies with:
pip install -r dev-requirements.txt # or pip install -e ".[dev]"
-
Run the style check
Run the
mypystyle check with:mypy xarrera tests
-
Run the tests
Run the tests with:
pytest
Generate the coverage with
pytest --cov=./ --cov-report=xml --verbose
License
All the code in this repository is MIT licensed.
History
This project was originally developed at CarbonPlan. It was transferred to the xarray-contrib organization in August 2022.
Due to the inactivity in xarray-contrib, it was forked to Xarrera in March 2026.
Authors
- Javier Gatón Herguedas - Maintainer - :octocat: @javgat - gaton@goa.uva.es
- Callan Gray - Contributor - :octocat: @calgray
- Joe Hamman - CarbonPlan - Initial Work - :octocat: @jhamman
- Anderson Banihirwe - CarbonPlan - Initial Work - :octocat @andersy005 - anderson@carbonplan.org
- Peter A. I. Forsyth - Initial Work - :octocat: @paiforsyth
- Oriana Chegwidden - CarbonPlan - Initial Work - :octocat: @orianac
- Raphael Hagen - CarbonPlan - Initial Work - raphael@carbonplan.org
Metadata
Release files for xarrera 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xarrera-0.0.5.tar.gz | 26.8 kB | Without provenance | Details for xarrera-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xarrera-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for xarrera-0.0.5-py3-none-any.whl |
Total release size: 40.5 kB
Release files / xarrera-0.0.5.tar.gz
| Download URL | xarrera-0.0.5.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6aff7335ec298400fd94e00b24418973792e1a49ed4cde7b7093b525e3e9e047
|
|
BLAKE2b-256 checksum How to use checksums |
78223ac1e05ab3fd2db59a45d2c27788d1ea0f5b7ddd17cc9b4c002453994b97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / xarrera-0.0.5-py3-none-any.whl
| Download URL | xarrera-0.0.5-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
794f80af9a8deec6923c84eb4e8388930ad5174ded125c2d42723c70cbf48a9f
|
|
BLAKE2b-256 checksum How to use checksums |
e8610c1e23794b93974adb8d020361fe763de75a2fdd0b4623a49bdf37e49c7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for xarrera 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.