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.3.1.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file pydantic-avro-0.3.1.tar.gz
.
File metadata
- Download URL: pydantic-avro-0.3.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.1 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fa56e43e93777326ab647ab4451fc5c6c55c306061df7c32454962fcb8ea415 |
|
MD5 | aeee5793c660d80ab4f2ca2044a47f63 |
|
BLAKE2b-256 | abc00ac89993eb4558c93223d4bedee4c29c3dab4f091c2da6e5d932c04bc8bf |
File details
Details for the file pydantic_avro-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: pydantic_avro-0.3.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.1 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1492923df62e900f67acbdccfd0afa6325dbe4be12d7050d6de29d648596c90 |
|
MD5 | befb5977611928ec3c3e97a5093bf97f |
|
BLAKE2b-256 | 11f9cf04a344143497b413cad72f2097db1e237f0029bfb67464b5b6475c9faa |