dc-avro


Namedc-avro JSON
Version 0.9.0 PyPI version JSON
download
home_page
Summary
upload_time2024-03-11 16:56:20
maintainer
docs_urlNone
authorMarcos Schroh
requires_python>=3.8,<4.0
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.8%2B-yellowgreen)

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

```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": "",
    "name": "dc-avro",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "avro,schemas,dataclasses,pydantic,lint",
    "author": "Marcos Schroh",
    "author_email": "marcos.schroh@kpn.com",
    "download_url": "https://files.pythonhosted.org/packages/c7/21/db23919d12184950fec8167354e21de0ed4e00cf3260d8f7be74d37b8f9e/dc_avro-0.9.0.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.8%2B-yellowgreen)\n\n## Requirements\n\n`python 3.8+`\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": "",
    "version": "0.9.0",
    "project_urls": null,
    "split_keywords": [
        "avro",
        "schemas",
        "dataclasses",
        "pydantic",
        "lint"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31426c7f1b50a05cd40dae80ceb9f4a57da78cfe86c66eea2d7b740234dc96b9",
                "md5": "00686c4e978bdde9c6e308f61d35bcf4",
                "sha256": "dc1b63f36a4da3fcb72320886aee84a0cf40244fc9d10bcbd2c252b8d451d788"
            },
            "downloads": -1,
            "filename": "dc_avro-0.9.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "00686c4e978bdde9c6e308f61d35bcf4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 6508,
            "upload_time": "2024-03-11T16:56:19",
            "upload_time_iso_8601": "2024-03-11T16:56:19.271123Z",
            "url": "https://files.pythonhosted.org/packages/31/42/6c7f1b50a05cd40dae80ceb9f4a57da78cfe86c66eea2d7b740234dc96b9/dc_avro-0.9.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c721db23919d12184950fec8167354e21de0ed4e00cf3260d8f7be74d37b8f9e",
                "md5": "ef3d56b74f1d6e9f43c3735acef5f9f3",
                "sha256": "dc74db8602f96bce62c4c423c303f3f01d76b84998e62b9f07699f44a6734170"
            },
            "downloads": -1,
            "filename": "dc_avro-0.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ef3d56b74f1d6e9f43c3735acef5f9f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 5531,
            "upload_time": "2024-03-11T16:56:20",
            "upload_time_iso_8601": "2024-03-11T16:56:20.303263Z",
            "url": "https://files.pythonhosted.org/packages/c7/21/db23919d12184950fec8167354e21de0ed4e00cf3260d8f7be74d37b8f9e/dc_avro-0.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-11 16:56:20",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dc-avro"
}
        
Elapsed time: 0.19950s