Giter VIP home page Giter VIP logo

fastavro-gen's People

Contributors

chwebdude avatar gudjonragnar avatar gunter-trooper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

fastavro-gen's Issues

Doc field does not get added to dataclass

Hello, I found this repository very helpful in my project.

I think a good feature would be using the doc field to generate some kind of documentation for the generated dataclasses. For example, with:

{
    "name" : "timestamp",
    "type" : {
      "type" : "long",
      "logicalType" : "timestamp-millis"
    },
    "doc" : "Unix time in milliseconds for the creation of this object. See: https://docs.com"
  }

This field would be used to document the intended use:

"doc" : "Unix time in milliseconds for the creation of this object. See: https://docs.com"

fastavro-gen not able to parse logical type decimal

Hi,

I am having issue generate python classes with this schema input

{
  "namespace": "com.edmw.issuerlist",
  "type": "record",
  "name": "IssuerListMember",
  "fields": [
    {"name": "IssuerListCode", "type": "string"},
    {"name": "IssuerUniqueIdentifiers", "type": {"type" : "array", "items": "long"}},
    {"name": "LastUpdateTimestamp", "type": {
      "type": "long",
      "logicalType":  "timestamp-millis"
    }},
    {
      "default": null,
      "name": "IssuerMarketCap",
      "type": [
               "null",
               {
                 "logicalType": "decimal",
                 "precision": 38,
                 "scale": 8,
                 "type": "bytes"
               }
              ]
     }
  ]
}

Here is the stack trace:

(venv) C:\Users\----\JetBrain\workspace\python\kafka_learning>fastavro_gen IssuerList.avsc
Parsing schema/s for IssuerList.avsc
Generate dataclasss...
Traceback (most recent call last):
  File "C:\Users\----\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\----\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\----\JetBrain\workspace\python\kafka_learning\venv\Scripts\fastavro_gen.exe\__main__.py", line 7, in <module>
  File "c:\users\----\jetbrain\workspace\python\kafka_learning\venv\lib\site-packages\fastavro_gen\__main__.py", line 56, in main
    read_schemas_and_generate_classes(
  File "c:\users\----\jetbrain\workspace\python\kafka_learning\venv\lib\site-packages\fastavro_gen\type_gen.py", line 280, in read_schemas_and_generate_classes
    generate_classes(
  File "c:\users\----\jetbrain\workspace\python\kafka_learning\venv\lib\site-packages\fastavro_gen\type_gen.py", line 243, in generate_classes
    write_schema(
  File "c:\users\----\jetbrain\workspace\python\kafka_learning\venv\lib\site-packages\fastavro_gen\type_gen.py", line 214, in write_schema
    write_record(
  File "c:\users\----\jetbrain\workspace\python\kafka_learning\venv\lib\site-packages\fastavro_gen\type_gen.py", line 164, in write_record
    t = _parse_type(field["type"], collector, namespace_prefix=namespace_prefix)
  File "c:\users\----\jetbrain\workspace\python\kafka_learning\venv\lib\site-packages\fastavro_gen\type_gen.py", line 71, in _parse_type
    return f"Optional[{_parse_type(_other[0], collector, namespace_prefix=namespace_prefix)}]"
  File "c:\users\----\jetbrain\workspace\python\kafka_learning\venv\lib\site-packages\fastavro_gen\type_gen.py", line 78, in _parse_type
    return _parse_dict_type(_type, collector, namespace_prefix=namespace_prefix)
  File "c:\users\----\jetbrain\workspace\python\kafka_learning\venv\lib\site-packages\fastavro_gen\type_gen.py", line 109, in _parse_dict_type
    raise Exception(f"Failed parsing type {_type}")
Exception: Failed parsing type {'logicalType': 'decimal', 'precision': 38, 'scale': 8, 'type': 'bytes'}

Setup GitHub Actions

  • Setup github actions to run tests and type check
  • Setup actions to build and deploy to pypi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.