Closed
Description
Description
We have an error ValueError: dictionary update sequence element #0 has length X; 2 is required
raised when using dict()
on a valid instance of FeatureCollection
.
How to reproduce
from geojson_pydantic import FeatureCollection
fc = FeatureCollection.model_validate({'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'properties': {}, 'geometry': {'type': 'Point', 'coordinates': [1, 2]}}]})
dict(fc) # <-- here
Expected
The call to dict
should return a dict
Observed
The call to dict
raises a ValueError
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 5; 2 is required
Why is this an issue
We are using FeatureCollection
as an input parameter type for a Prefect flow.
It looks something like this
# Flow definition
@flow(name="my_flow")
async def my_flow(area: FeatureCollection):
return "yes"
my_flow(....) # Flow usage
It turns out that Prefect, since version 3.2.16 we believe, start applying a dict
on flows input parameters if these parameters are Pydantic models (see here)
Since the dict
fails on FeatureCollection
s, it makes unusable in this context.
Metadata
Metadata
Assignees
Labels
No labels