You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pydantic avro is unable to handle module below type mentioned for vertices. It seems inside the list, Tuple and Union is not handled. Can you verify the same if it is supported by the module?
---------------------------------------------------------------------------AttributeErrorTraceback (mostrecentcalllast)
CellIn[13], line1---->1PolygonModel.avro_schema()
File~/.pyenv/versions/3.11.0/envs/jupyter/lib/python3.11/site-packages/pydantic_avro/base.py:29, inAvroBase.avro_schema(cls, by_alias, namespace)
25ifnamespaceisNone:
26# default namespace will be based on title27namespace=schema["title"]
--->29returncls._avro_schema(schema, namespace)
File~/.pyenv/versions/3.11.0/envs/jupyter/lib/python3.11/site-packages/pydantic_avro/base.py:186, inAvroBase._avro_schema(schema, namespace)
183fields.append(avro_type_dict)
184returnfields-->186fields=get_fields(schema)
187print(fields)
188return {"type": "record", "namespace": namespace, "name": schema["title"], "fields": fields}
File~/.pyenv/versions/3.11.0/envs/jupyter/lib/python3.11/site-packages/pydantic_avro/base.py:167, inAvroBase._avro_schema.<locals>.get_fields(s)
165required=s.get("required", [])
166forkey, valueins.get("properties", {}).items():
-->167avro_type_dict=get_type(value)
168avro_type_dict["name"] =key170ifkeynotinrequired:
File~/.pyenv/versions/3.11.0/envs/jupyter/lib/python3.11/site-packages/pydantic_avro/base.py:90, inAvroBase._avro_schema.<locals>.get_type(value)
88elift=="array":
89items=value.get("items")
--->90tn=get_type(items)
91# If items in array are a object:92if"$ref"initems:
File~/.pyenv/versions/3.11.0/envs/jupyter/lib/python3.11/site-packages/pydantic_avro/base.py:90, inAvroBase._avro_schema.<locals>.get_type(value)
88elift=="array":
89items=value.get("items")
--->90tn=get_type(items)
91# If items in array are a object:92if"$ref"initems:
File~/.pyenv/versions/3.11.0/envs/jupyter/lib/python3.11/site-packages/pydantic_avro/base.py:48, inAvroBase._avro_schema.<locals>.get_type(value)
46"""Returns a type of a single field"""47print(value)
--->48t=value.get("type")
49f=value.get("format")
50r=value.get("$ref")
AttributeError: 'NoneType'objecthasnoattribute'get'
The text was updated successfully, but these errors were encountered:
sushilkjaiswar
changed the title
Support for enum type defined in Pydantic class
Support for List with Tuple and Union type defined in Pydantic class
Nov 29, 2023
There are multiple issues here. I think the main one is that the pydantic-avro library is going to try and turn PolygonType into an enum in the avro schema. Unfortunately enums in the avro schema have a requirement for the values of the enums (link to docs). Just a number is not going to work. Probably the easiest workaround is to either turn your enum to have matching string values like what is below or just turn the field into an int.
With python 3.11 you can use StrEnum (python docs):
I have a PR open to support unions within the list. However there is another bug in which tuple is not supported either. I'll see if I can put that into my existing PR as well.
The pydantic avro is unable to handle module below type mentioned for
vertices
. It seems inside the list, Tuple and Union is not handled. Can you verify the same if it is supported by the module?e.g.
error
The text was updated successfully, but these errors were encountered: