dc-avro


Namedc-avro JSON
Version 0.9.3 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-10-23 09:43:28
maintainerNone
docs_urlNone
authorMarcos Schroh
requires_python<4.0,>=3.9
licenseMIT
keywords avro schemas dataclasses pydantic lint
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dataclasses Avro Schema CLI

Command line interface from [dataclasses-avroschema](https://github.com/marcosschroh/dataclasses-avroschema) to work with `avsc` resources

[![Tests](https://github.com/marcosschroh/dc-avro/actions/workflows/tests.yaml/badge.svg)](https://github.com/marcosschroh/dc-avro/actions/workflows/tests.yaml)
[![GitHub license](https://img.shields.io/github/license/marcosschroh/dc-avro.svg)](https://github.com/marcosschroh/dc-avro/blob/master/LICENSE)
[![codecov](https://codecov.io/gh/marcosschroh/dc-avro/branch/master/graph/badge.svg)](https://codecov.io/gh/marcosschroh/dc-avro)
![python version](https://img.shields.io/badge/python-3.9%2B-yellowgreen)

## Requirements

`python 3.9+`

## 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

```bash
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

```bash
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

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

## Features

* [x] Validate `schema`
* [x] Lint `schemas`
* [x] Generate `models` from `schemas`
* [x] Data deserialization with `schema`
* [x] Data serialization with `schema`
* [x] 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`

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dc-avro",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "avro, schemas, dataclasses, pydantic, lint",
    "author": "Marcos Schroh",
    "author_email": "marcos.schroh@kpn.com",
    "download_url": "https://files.pythonhosted.org/packages/57/92/b4836bae867256cf190995915385206937591714ed6ac0a3a7786b3b19a8/dc_avro-0.9.3.tar.gz",
    "platform": null,
    "description": "# Dataclasses Avro Schema CLI\n\nCommand line interface from [dataclasses-avroschema](https://github.com/marcosschroh/dataclasses-avroschema) to work with `avsc` resources\n\n[![Tests](https://github.com/marcosschroh/dc-avro/actions/workflows/tests.yaml/badge.svg)](https://github.com/marcosschroh/dc-avro/actions/workflows/tests.yaml)\n[![GitHub license](https://img.shields.io/github/license/marcosschroh/dc-avro.svg)](https://github.com/marcosschroh/dc-avro/blob/master/LICENSE)\n[![codecov](https://codecov.io/gh/marcosschroh/dc-avro/branch/master/graph/badge.svg)](https://codecov.io/gh/marcosschroh/dc-avro)\n![python version](https://img.shields.io/badge/python-3.9%2B-yellowgreen)\n\n## Requirements\n\n`python 3.9+`\n\n## Documentation\n\nhttps://marcosschroh.github.io/dc-avro/\n\n## Usage\n\nYou can validate one `avro schema` either from a `local file` or `url`:\n\nAssuming that we have a local file `schema.avsc` that contains an `avro schema`, we can check whether it is valid\n\n```bash\ndc-avro validate-schema --path schema.avsc\n\nValid schema!! \ud83d\udc4d \n\n{\n    'type': 'record',\n    'name': 'UserAdvance',\n    'fields': [\n        {'name': 'name', 'type': 'string'},\n        {'name': 'age', 'type': 'long'},\n        {'name': 'pets', 'type': {'type': 'array', 'items': 'string', 'name': 'pet'}},\n        {'name': 'accounts', 'type': {'type': 'map', 'values': 'long', 'name': 'account'}},\n        {'name': 'favorite_colors', 'type': {'type': 'enum', 'name': 'FavoriteColor', 'symbols': ['BLUE', 'YELLOW', 'GREEN']}},\n        {'name': 'has_car', 'type': 'boolean', 'default': False},\n        {'name': 'country', 'type': 'string', 'default': 'Argentina'},\n        {'name': 'address', 'type': ['null', 'string'], 'default': None},\n        {'name': 'md5', 'type': {'type': 'fixed', 'name': 'md5', 'size': 16}}\n    ]\n}\n```\n\nYou can validate several `.avsc` files with `lint` command\n\n```bash\ndc-avro lint tests/schemas/example.avsc tests/schemas/example_v2.avsc\n\n\ud83d\udc4d Total valid schemas: 2\ntests/schemas/example.avsc\ntests/schemas/example_v2.avsc\n```\n\nTo see all the commands execute `dc-avro --help`\n\n## Usage in pre-commit\n\nAdd the following lines to your `.pre-commit-config.yaml` file to enable avro schemas linting\n\n```yaml\n  - repo: https://github.com/marcosschroh/dc-avro.git\n    rev: 0.7.0\n    hooks:\n      - id: lint-avsc\n        additional_dependencies: [typing_extensions]\n```\n\n## Features\n\n* [x] Validate `schema`\n* [x] Lint `schemas`\n* [x] Generate `models` from `schemas`\n* [x] Data deserialization with `schema`\n* [x] Data serialization with `schema`\n* [x] View diff between `schemas`\n* [ ] Generate fake data from `schema`\n\n## Development\n\n1. Install requirements: `poetry install`\n2. Code linting: `./scripts/format`\n3. Run tests: `./scripts/test`\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": null,
    "version": "0.9.3",
    "project_urls": null,
    "split_keywords": [
        "avro",
        " schemas",
        " dataclasses",
        " pydantic",
        " lint"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae3086efbd60fa77bf9821906c82c702039501a533f1c66a55108f610bbd0370",
                "md5": "690c3781f245387de4ce4a5e1e084228",
                "sha256": "b0edda1466ba2f02313f7ecbc324b3ccddd52a19ad157fda21a555e6e71d9007"
            },
            "downloads": -1,
            "filename": "dc_avro-0.9.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "690c3781f245387de4ce4a5e1e084228",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 6521,
            "upload_time": "2024-10-23T09:43:27",
            "upload_time_iso_8601": "2024-10-23T09:43:27.680662Z",
            "url": "https://files.pythonhosted.org/packages/ae/30/86efbd60fa77bf9821906c82c702039501a533f1c66a55108f610bbd0370/dc_avro-0.9.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5792b4836bae867256cf190995915385206937591714ed6ac0a3a7786b3b19a8",
                "md5": "ec718e7d36cf898340e5fc405deb90f0",
                "sha256": "0a482e284637b710974084cb809c80d7a9be8275a6a7bacde1184fb1dbbdd6c1"
            },
            "downloads": -1,
            "filename": "dc_avro-0.9.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ec718e7d36cf898340e5fc405deb90f0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 5546,
            "upload_time": "2024-10-23T09:43:28",
            "upload_time_iso_8601": "2024-10-23T09:43:28.584005Z",
            "url": "https://files.pythonhosted.org/packages/57/92/b4836bae867256cf190995915385206937591714ed6ac0a3a7786b3b19a8/dc_avro-0.9.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-23 09:43:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dc-avro"
}
        
Elapsed time: 2.48140s