Skip to main content

No project description provided

Project description

Dataclasses Avro Schema CLI

Command line interface from dataclasses-avroschema to work with avsc resources

Tests GitHub license codecov python version

Requirements

python 3.8+

Documentation

https://marcosschroh.github.io/dc-avro/

Usage

You can validate one avro schema either from a local file or url:

Assuming that we have a local file schema.avsc that contains an avro schema, we can check whether it is valid

dc-avro validate-schema --path schema.avsc

Valid schema!! 👍 

{
    'type': 'record',
    'name': 'UserAdvance',
    'fields': [
        {'name': 'name', 'type': 'string'},
        {'name': 'age', 'type': 'long'},
        {'name': 'pets', 'type': {'type': 'array', 'items': 'string', 'name': 'pet'}},
        {'name': 'accounts', 'type': {'type': 'map', 'values': 'long', 'name': 'account'}},
        {'name': 'favorite_colors', 'type': {'type': 'enum', 'name': 'FavoriteColor', 'symbols': ['BLUE', 'YELLOW', 'GREEN']}},
        {'name': 'has_car', 'type': 'boolean', 'default': False},
        {'name': 'country', 'type': 'string', 'default': 'Argentina'},
        {'name': 'address', 'type': ['null', 'string'], 'default': None},
        {'name': 'md5', 'type': {'type': 'fixed', 'name': 'md5', 'size': 16}}
    ]
}

You can validate several .avsc files with lint command

dc-avro lint tests/schemas/example.avsc tests/schemas/example_v2.avsc

👍 Total valid schemas: 2
tests/schemas/example.avsc
tests/schemas/example_v2.avsc

To see all the commands execute dc-avro --help

Usage in pre-commit

Add the following lines to your .pre-commit-config.yaml file to enable avro schemas linting

  - repo: https://github.com/marcosschroh/dc-avro.git
    rev: 0.7.0
    hooks:
      - id: lint-avsc
        additional_dependencies: [typing_extensions]

Features

  • Validate schema
  • Lint schemas
  • Generate models from schemas
  • Data deserialization with schema
  • Data serialization with schema
  • View diff between schemas
  • Generate fake data from schema

Development

  1. Install requirements: poetry install
  2. Code linting: ./scripts/format
  3. Run tests: ./scripts/test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dc_avro-0.9.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

dc_avro-0.9.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file dc_avro-0.9.2.tar.gz.

File metadata

  • Download URL: dc_avro-0.9.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for dc_avro-0.9.2.tar.gz
Algorithm Hash digest
SHA256 0428ad83c67fcb5d48935bd2406598ef850d3deca0dd50f232b02761291d720b
MD5 67c98b039510dcafc0bb82118427f68e
BLAKE2b-256 6a93e25ccab428228289abcf4918180404e07e4ba73fc4412363b1a3b27500d4

See more details on using hashes here.

File details

Details for the file dc_avro-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: dc_avro-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for dc_avro-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71d5620f432f559223e452ac6d7b807ec5c2489d97c2eed55b755cc9f87935ce
MD5 30fdd8c1cfb8cffa28bf1469380b5027
BLAKE2b-256 3ae6f7c5a4b2cf4df63ef14653016c50538ce5b846d2a642d89386f8dc850a1d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page