Converting pydantic classes to avro schemas
Project description
pydantic-avro
This library can convert a pydantic class to a avro schema or generate python code from a avro schema.
Install
pip install pydantic-avro
Pydantic class to avro schema
import json
from typing import Optional
from pydantic_avro.base import AvroBase
class TestModel(AvroBase):
key1: str
key2: int
key2: Optional[str]
schema_dict: dict = TestModel.avro_schema()
print(json.dumps(schema_dict))
Avro schema to pydantic
# Print to stdout
pydantic-avro avro_to_pydantic --asvc /path/to/schema.asvc
# Save it to a file
pydantic-avro avro_to_pydantic --asvc /path/to/schema.asvc --output /path/to/output.py
Install for developers
Install package
- Requirement: Poetry 1.*
poetry install
Run unit tests
pytest
coverage run -m pytest # with coverage
# or (depends on your local env)
poetry run pytest
poetry run coverage run -m pytest # with coverage
Run linting
The linting is checked in the github workflow. To fix and review issues run this:
black . # Auto fix all issues
isort . # Auto fix all issues
pflake . # Only display issues, fixing is manual
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydantic_avro-0.6.3.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file pydantic_avro-0.6.3.tar.gz
.
File metadata
- Download URL: pydantic_avro-0.6.3.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.9.17 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e24a508aef2957b82939bc446c9b2785dd4405c60c9ecba09e612d083a729426 |
|
MD5 | d7199692e230690df6d42e7dbe1fcfc6 |
|
BLAKE2b-256 | 0c18dfc3cff04a4fe0cef1ac3252a0f2fab495b6cff7ba8d9ae33728cab88ae3 |
File details
Details for the file pydantic_avro-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: pydantic_avro-0.6.3-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.9.17 Linux/5.15.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a7a0987551b1270964691bffc8d3b1b1295dc7ecc4c486a0f851bc7548c9efb |
|
MD5 | c09dd891b0bf11baa8eda88ec3edc3ee |
|
BLAKE2b-256 | cc5d5164b3caf06d7465128ed38d4a5fd781ade9a33a2b9df11eaf9e6ea72840 |