Closed thevops closed 11 months ago
You are welcome! Oops, pydantic v2 seems incompatible with v1. Feel free to PR to change it (should be a good first issue
), e.g. fixing version to 1.x
Sorry to revive this old issue, but still the same problem occur when I create a virtualenv with pyenv, using python 3.10 like this:
pyenv local 3.10
pyenv virtualenv 3.10 grafanalib
pyenv activate grafanalib
pip install grafana_dashboard
...
grafana_dashboard json-to-python --json-path ~/workspace/ionos/helm-charts/charts/base-cluster-service/dashboards/container-image-versions-overview.json --python-path .
Traceback (most recent call last):
File "/home/skoenig/.pyenv/versions/grafanalib/bin/grafana_dashboard", line 5, in <module>
from grafana_dashboard.grafana_dashboard import run
File "/home/skoenig/.pyenv/versions/3.10.14/envs/grafanalib/lib/python3.10/site-packages/grafana_dashboard/grafana_dashboard.py", line 5, in <module>
import grafana_dashboard.converter.json_to_python
File "/home/skoenig/.pyenv/versions/3.10.14/envs/grafanalib/lib/python3.10/site-packages/grafana_dashboard/converter/json_to_python.py", line 8, in <module>
from grafana_dashboard.model.dashboard_types_gen import Dashboard
File "/home/skoenig/.pyenv/versions/3.10.14/envs/grafanalib/lib/python3.10/site-packages/grafana_dashboard/model/dashboard_types_gen.py", line 11, in <module>
from grafana_dashboard.model import timeseriespanelcfg_types_gen, piechartpanelcfg_types_gen
File "/home/skoenig/.pyenv/versions/3.10.14/envs/grafanalib/lib/python3.10/site-packages/grafana_dashboard/model/timeseriespanelcfg_types_gen.py", line 124, in <module>
class TimeZone(MyBaseModel):
File "/home/skoenig/.pyenv/versions/3.10.14/envs/grafanalib/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 93, in __new__
private_attributes = inspect_namespace(
File "/home/skoenig/.pyenv/versions/3.10.14/envs/grafanalib/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 349, in inspect_namespace
raise TypeError("To define root models, use `pydantic.RootModel` rather than a field called '__root__'")
TypeError: To define root models, use `pydantic.RootModel` rather than a field called '__root__'
Seems like the upper version limit for Pydantic defined in #3 is not taking effect:
pip list
Package Version
----------------- -------
annotated-types 0.7.0
click 8.1.7
grafana-dashboard 0.1.1
markdown-it-py 3.0.0
mdurl 0.1.2
pip 24.0
pydantic 2.7.4
pydantic_core 2.18.4
Pygments 2.18.0
rich 13.7.1
setuptools 70.0.0
shellingham 1.5.4
typer 0.12.3
typing_extensions 4.12.2
wheel 0.43.0
If I downgrade to the Pydantic version as defined in setup.py
with pip install 'pydantic>=1.10.2,<2'
, I get the dashboard defined in Python code.
Hmm, what about using the code on master branch, does it work for you?
My virtual environment, after
pip install grafana_dashboard
:Error:
Temporary solution (downgrade pydantic):
I think that something has changed in pydantic library.
By the way, nice tool :) thanks