Conversion from pydantic models to pyarrow schemas
Low maintenance activity. Last release 22 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and recent releases.
pip install pydantic-to-pyarrowpydantic-to-pyarrow
pydantic-to-pyarrow is a library for Python to help with conversion of pydantic models to pyarrow schemas.
(Please note that this project is not affiliated in any way with the great teams at pydantic or pyarrow.)
pydantic is a Python library for data validation, applying type hints / annotations. It enables the creation of easy or complex data validation rules.
pyarrow is a Python library for using Apache Arrow, a development platform for in-memory analytics. The library also enables easy writing to parquet files.
Why might you want to convert models to schemas? One scenario is for a data processing pipeline:
- Import / extract the data from its source
- Validate the data using pydantic
- Process the data in pyarrow / pandas / polars
- Store the raw and / or processed data in parquet.
The easiest approach for steps 3 and 4 above is to let pyarrow infer the schema from the data. The most involved approach is to specify the pyarrow schema separate from the pydantic model. In the middle, many applications could benefit from converting the pydantic model to a pyarrow schema. This library aims to achieve that.
Installation
pip install pydantic-to-pyarrow
Note: PyArrow versions < 15 are only compatible with NumPy 1.x, but they do not express this in their dependency constraints. If other constraints are forcing you to use PyArrow < 15 on Python 3.9+, and you see errors like 'A module that was compiled using NumPy 1.x cannot be run in Numpy 2.x ...', then try forcing NumPy 1.x in your project's dependencies.