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.7.0.tar.gz
(8.7 kB
view details)
Built Distribution
File details
Details for the file pydantic_avro-0.7.0.tar.gz
.
File metadata
- Download URL: pydantic_avro-0.7.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.9.19 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82bbce516cbf4c7909252b710cce50ffbbb866806b62a6be9fd2167a024515de |
|
MD5 | ce2672c350a1623bb5d3511d457e44dc |
|
BLAKE2b-256 | f1b778173ca010b4a829f246fe71e6383340c9dcc6c4964f029a15a5938345aa |
File details
Details for the file pydantic_avro-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: pydantic_avro-0.7.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.9.19 Linux/6.5.0-1021-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fa820f3706df5c7ede93544b3b64efb2da1f0f45299ec41288e847bc3f332a7 |
|
MD5 | ed531bd5521fde3167a03b8411173ec9 |
|
BLAKE2b-256 | 1e5a379b93897f51960a343f9877ca4df6878961ae17b5be002936ee24963884 |