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.2.4.tar.gz
(5.9 kB
view details)
Built Distribution
File details
Details for the file pydantic-avro-0.2.4.tar.gz
.
File metadata
- Download URL: pydantic-avro-0.2.4.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09421f1480e7fd613b29667559dec86f7218578c67b951302c399de723164428 |
|
MD5 | f8b81823aebc0119c57f28fecbc66e3f |
|
BLAKE2b-256 | a2f2ec13f56b784e69c8fd845b9f4b7f7f5f8df43320d2c29958c352207a33ac |
File details
Details for the file pydantic_avro-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: pydantic_avro-0.2.4-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c1f867787c60663d84bcd261c78d52b37c4035944872488655754af072b2448 |
|
MD5 | 20fb392820a85d4f1507ab5d09bd355e |
|
BLAKE2b-256 | 86725e6b2eaa40fe0eac41eb3b9344a6b17ec0199ec45a9c191c3d52540dec18 |