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.0.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file pydantic-avro-0.3.0.tar.gz
.
File metadata
- Download URL: pydantic-avro-0.3.0.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 | b328c99dffca2ec68889ba0c615ab9665775d458312fd01b3f6659766dc39fbd |
|
MD5 | 0792f6f4af2e569b1e8216faf6eba00c |
|
BLAKE2b-256 | 5508d4dbbba13222a08fca5d8116fbceb61570158cfc6ac18f3e7fb104a0e868 |
File details
Details for the file pydantic_avro-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: pydantic_avro-0.3.0-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 | bacb9d0fd28ff13423d42237d0a5f870c8360c2abf99490c590ccf9b23eede81 |
|
MD5 | 9d1dfb79fe29faf91c64c30973e5cc72 |
|
BLAKE2b-256 | 55cde736d64554e8e783dc59b839d9f75251c2901ff4e2f0c1ec97f8d066dd47 |