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.1.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file pydantic_avro-0.6.1.tar.gz
.
File metadata
- Download URL: pydantic_avro-0.6.1.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 | d09a6d42930a4e14dc92fc7b60045d005c38eb3bd52f4c3e9122eb0e9e6759b5 |
|
MD5 | 0ac65f9db7e13ee8337f73e46ce0fd84 |
|
BLAKE2b-256 | 49f44e0649046d5cf0eeb9e25917cd51f3ecae155a993f1dd81f6bc1f94a1c4b |
File details
Details for the file pydantic_avro-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: pydantic_avro-0.6.1-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 | e67229367e74323c65fab7a8322414d7794e08fe3e956d768aaa260784b4df06 |
|
MD5 | ba7c40c13a410c8d8f4ae986b370cda7 |
|
BLAKE2b-256 | 0b4a6fc6ce4c6cdc4052b7d0be5ea5319cc51cae71d438e33fbe019235fe5dd9 |