"duplicate validator function" error while importing Feature class form geojson_pydantic
vishalratnam6 opened this issue ยท 10 comments
I've created a dataclass Abc
:
from geojson_pydantic import Feature
from dataclasses import dataclass
@dataclass
class Abc:
geojson: Feature
myid: uuid.UUID
This model is present in commons.py
file inside dtos
folder.
I'm trying to import Abc from main.py
and one other file.
Directory Structure:
src -->
--> dtos
- commons.py -> Abc
--> anothermodule
- create.py -> from dtos.commons import Abc
main.py -> import dtos.commons.Abc
I get this error when I run the main.py
file
File "<frozen importlib._bootstrap>", line 1109, in __import__
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/local/anaconda3/envs/apsbackend/lib/python3.9/site-packages/geojson_pydantic/geometries.py", line 175, in <module>
class Polygon(_GeometryBase):
File "/usr/local/anaconda3/envs/apsbackend/lib/python3.9/site-packages/geojson_pydantic/geometries.py", line 186, in Polygon
def check_closure(cls, coordinates: List) -> List:
File "pydantic/class_validators.py", line 93, in pydantic.class_validators.validator.dec
File "pydantic/class_validators.py", line 156, in pydantic.class_validators._prepare_validator
pydantic.errors.ConfigError: duplicate validator function "geojson_pydantic.geometries.Polygon.check_closure"; if this is intended, set `allow_reuse=True`
@vishalratnam6 can you tell what version of geojson-pydantic you are using please ๐
@vincentsarago I'm using the latest version of geojson-pydantic, version 0.6.0
I've tried something locally but I haven't been able to reproduce your issue ๐คทโโ๏ธ
I've started #121 but this is pure guess. could you try this branch and see if it fix your issue?
Hey @vincentsarago,
I tried, and I get this error now!:
File "<frozen importlib._bootstrap>", line 1109, in __import__
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/local/anaconda3/envs/apsbackend/lib/python3.9/site-packages/geojson_pydantic/geometries.py", line 175, in <module>
class Polygon(_GeometryBase):
File "/usr/local/anaconda3/envs/apsbackend/lib/python3.9/site-packages/geojson_pydantic/geometries.py", line 186, in Polygon
def check_closure_poly(cls, coordinates: List) -> List:
File "pydantic/class_validators.py", line 93, in pydantic.class_validators.validator.dec
File "pydantic/class_validators.py", line 156, in pydantic.class_validators._prepare_validator
pydantic.errors.ConfigError: duplicate validator function "geojson_pydantic.geometries.Polygon.check_closure_poly"; if this is intended, set `allow_reuse=True`
For more context, all this happens in temporal worflows.
The main.py
file imports the Abc
class and starts a workflow defined in create.py
. So in main.py
I do import create.my_workflow
as well. I'm guessing there is some kind of multiple import going on for the Feature
class.
ok I closed #121 because it's definitely not what I though.
This is really weird. Did you get the same error when using version 0.5
?
Cool ๐
I'm really sorry, but without a proper reproducible example it's really hard for me to help more ๐ญ
@vishalratnam6 I think it would be simpler if you create a small repo in GitHub with a simple reproductible example ๐
Hey @vincentsarago, I've created this repo.
You'll need to install temporal and start the server locally.
Then you've to run pip install temporalio
and obv pip install geojson_pydantic
.
Post this, if you run python3 main.py
, it'll throw the same error!
I don't think this is a geojson-pydantic issue! There's definitely something going on with Temporal. I provided a fix
directly in the example repo so I'm going to close this issue for now ๐