datnguye / dbterd

Generate the ERD as a code from dbt artifacts
https://dbterd.datnguyen.de/
MIT License
198 stars 28 forks source link

[BUG] dbt 1.8 and Python 3.12 causes failure #123

Closed CraigWilson-ZOE closed 3 weeks ago

CraigWilson-ZOE commented 3 weeks ago

Describe the bug When trying to run any dbterd command, even dbterd --version causes a stacktrace to be output

To Reproduce Steps to reproduce the behavior:

Environment setup:

  1. Run the command dbterd --version stack trace produced

Expected behavior The command not to produce a stack trace and run without error e.g. dbterd --version to output a version string.

Screenshots Screenshot 2024-08-20 at 14 20 55

Desktop (please complete the following information):

Running logs (if possible):

Traceback (most recent call last):
  File "/Users/datageekdude/.pyenv/versions/zdbt/bin/dbterd", line 5, in <module>
    from dbterd.main import main
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/dbterd/main.py", line 1, in <module>
    from dbterd.cli import main as cli
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/dbterd/cli/main.py", line 7, in <module>
    from dbterd.adapters.base import Executor
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/dbterd/adapters/base.py", line 9, in <module>
    from dbterd.adapters.dbt_cloud.administrative import DbtCloudArtifact
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/dbterd/adapters/dbt_cloud/administrative.py", line 6, in <module>
    from dbterd.helpers import file
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/dbterd/helpers/file.py", line 5, in <module>
    from dbt_artifacts_parser import parser
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/dbt_artifacts_parser/parser.py", line 20, in <module>
    from dbt_artifacts_parser.parsers.manifest.manifest_v1 import ManifestV1
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/dbt_artifacts_parser/parsers/manifest/manifest_v1.py", line 17, in <module>
    class ManifestMetadata(BaseParserModel):
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 200, in __new__
    set_model_fields(cls, bases, config_wrapper, types_namespace)
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 469, in set_model_fields
    fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/pydantic/_internal/_fields.py", line 132, in collect_model_fields
    type_hints = get_cls_type_hints_lenient(cls, types_namespace)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/pydantic/_internal/_typing_extra.py", line 228, in get_cls_type_hints_lenient
    hints[name] = eval_type_lenient(value, globalns, localns)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/pydantic/_internal/_typing_extra.py", line 240, in eval_type_lenient
    return eval_type_backport(value, globalns, localns)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/datageekdude/.pyenv/versions/3.12.2/envs/zdbt/lib/python3.12/site-packages/pydantic/_internal/_typing_extra.py", line 264, in eval_type_backport
    return typing._eval_type(  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/datageekdude/.pyenv/versions/3.12.2/lib/python3.12/typing.py", line 400, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/datageekdude/.pyenv/versions/3.12.2/lib/python3.12/typing.py", line 907, in _evaluate
    eval(self.__forward_code__, globalns, localns),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <module>
TypeError: constr() got an unexpected keyword argument 'regex'

Additional context N/A

datnguye commented 3 weeks ago

Thanks @CraigWilson-ZOE for raising the issue!

I will take a look… 🏃

👀 My hunch now is something to deal with dbt-artifacts-parser, might you want to try below command to see if it would work?

pip install dbterd
pip install dbt-artifacts-parser==0.6.0

Thanks

CraigWilson-ZOE commented 3 weeks ago

Ah thanks! Yes that seems to have worked.

We use Poetry to do the install and it seems it didn't pick up the dependency to update that library too. Thanks.

datnguye commented 3 weeks ago

Ah thanks! Yes that seems to have worked.

We use Poetry to do the install and it seems it didn't pick up the dependency to update that library too. Thanks.

Great!

FYI: We decided to relax the pinned version of dbt-artifacts-parser (here) because we wouldn't want to release newer versions everytime dbt-artifacts-parser got the new ones (meaning new dbt core version released).

In the meantime, I've tried to pay the attention in the home page but will be great if you could suggest something better here. Thanks 🙌 🙏