PicnicSupermarket / dbt-score

Linter for dbt metadata
https://dbt-score.picnic.tech
MIT License
95 stars 7 forks source link

ModuleNotFoundError: No module named 'dbt.adapters.factory' #49

Closed alittlesliceoftom closed 4 months ago

alittlesliceoftom commented 5 months ago

Likely lack of pegging release to specific versions of dbt?

My versions to get above error after doing a straight pip install: dbt-adapters 1.2.1 dbt-common 1.3.0 dbt-core 1.8.2 dbt-extractor 0.5.1 dbt-score 0.1.3 dbt-semantic-interfaces 0.5.1 dbt-sqlserver 1.4.3 dbt-synapse 1.4.0

alittlesliceoftom commented 5 months ago

Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code
File "C:\projects\dbt_clones\dbtenv\Scripts\dbt-score.exe__main.py", line 4, in File "C:\projects\dbt_clones\dbtenv\Lib\site-packages\dbt_score\init.py", line 3, in from dbt_score.models import Model File "C:\projects\dbt_clones\dbtenv\Lib\site-packages\dbt_score\models.py", line 11, in from dbt_score.dbt_utils import dbt_ls File "C:\projects\dbt_clones\dbtenv\Lib\site-packages\dbt_score\dbt_utils.py", line 8, in
from dbt.cli.main import dbtRunner, dbtRunnerResult File "C:\projects\dbt_clones\dbtenv\Lib\site-packages\dbt\cli\
init__.py", line 1, in from .main import cli as dbt_cli # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\projects\dbt_clones\dbtenv\Lib\site-packages\dbt\cli\main.py", line 14, in from dbt.cli import requires, params as p File "C:\projects\dbt_clones\dbtenv\Lib\site-packages\dbt\cli\requires.py", line 10, in from dbt.adapters.factory import adapter_management, register_adapter, get_adapter ModuleNotFoundError: No module named 'dbt.adapters.factory'

matthieucan commented 5 months ago

Thanks for the report. It's odd that, looking at the stacktrace, the failure seems to happen in imports only within the dbt-core source code. Can you share your setup in terms of Python installation? Are you using a virtual environment?

alittlesliceoftom commented 5 months ago

Venv with python 3.11

Tom O'Neill

On Tue, 11 Jun 2024 at 17:11, Matthieu Caneill @.***> wrote:

Thanks for the report. It's odd that, looking at the stacktrace, the failure seems to happen in imports only within the dbt-core source code. Can you share your setup in terms of Python installation? Are you using a virtual environment?

— Reply to this email directly, view it on GitHub https://github.com/PicnicSupermarket/dbt-score/issues/49#issuecomment-2161138487, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVRBJOMD2LD7HBXX2ZSLZ3ZG4OTPAVCNFSM6AAAAABJEMNKC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRRGEZTQNBYG4 . You are receiving this because you authored the thread.Message ID: @.***>

matthieucan commented 5 months ago

Does dbt work in that environment? I would suspect it also has import issues?

druzhinin-kirill commented 5 months ago

Hey! I was able to reproduce this issue on 3.11 with tox :

ImportError while loading conftest '.../dbt-score/tests/conftest.py'.
tests/conftest.py:7: in <module>
    from dbt_score import Model, Rule, RuleViolation, Severity, rule
.tox/py310/lib/python3.10/site-packages/dbt_score/__init__.py:3: in <module>
    from dbt_score.models import Model
.tox/py310/lib/python3.10/site-packages/dbt_score/models.py:11: in <module>
    from dbt_score.dbt_utils import dbt_ls
.tox/py310/lib/python3.10/site-packages/dbt_score/dbt_utils.py:8: in <module>
    from dbt.cli.main import dbtRunner, dbtRunnerResult
.tox/py310/lib/python3.10/site-packages/dbt/cli/__init__.py:1: in <module>
    from .main import cli as dbt_cli  # noqa
.tox/py310/lib/python3.10/site-packages/dbt/cli/main.py:14: in <module>
    from dbt.cli import requires, params as p
.tox/py310/lib/python3.10/site-packages/dbt/cli/requires.py:10: in <module>
    from dbt.adapters.factory import adapter_management, register_adapter, get_adapter
E   ModuleNotFoundError: No module named 'dbt.adapters.factory'

I believe we are affected by this https://github.com/dbt-labs/dbt-core/issues/10135

As restricting to <1.8 resolves it:

"dbt-core>=1.5, <1.8"
druzhinin-kirill commented 5 months ago

@alittlesliceoftom could you try out some of the suggestions made in the related dbt-core issue thread and see if it helps you?

druzhinin-kirill commented 4 months ago

Hey! I'll close the issue as it's probably caused by the upstream issue in the dbt-core. Try out some of the suggestions mentioned there and see if it helps you 🙌 If you continue experiencing the problem or need more information or context, feel free to reopen this issue 👍

mirimgtec commented 2 months ago

I am experiencing same issue when trying to use dbt-core 1.8.4 with dbt-metricflow 0.206.0. I am also using dbt-snowflake adapter.

matthieucan commented 2 months ago

I am experiencing same issue when trying to use dbt-core 1.8.4 with dbt-metricflow 0.206.0. I am also using dbt-snowflake adapter.

Any chance the hints in https://github.com/dbt-labs/dbt-core/issues/10135 can help?