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.5.0.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file pydantic_avro-0.5.0.tar.gz
.
File metadata
- Download URL: pydantic_avro-0.5.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.9.16 Linux/5.15.0-1035-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7a7b105cabef2bc2bb81baed0468b8c4ca3892b7399bec07c76a1b75e3438c5 |
|
MD5 | 8844a5341634bdf0f57eb8d2727c7585 |
|
BLAKE2b-256 | 0f87f5f15cfa6635055747032964235aa891a4395051f9fafd555436a44c6c2e |
File details
Details for the file pydantic_avro-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: pydantic_avro-0.5.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.9.16 Linux/5.15.0-1035-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f8abf3945d8b224e64485dda9160ae6f2f517ddf842b4d8ff46f2587a5a1005 |
|
MD5 | d25b12f78c7821849112b608a7ff1b7b |
|
BLAKE2b-256 | 2d56ece147f489b44fdbccb37f27c2170fd9e997d2f1d0b7c41c4ef24fc5751a |