Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Set the dbt invocation context before loading the profile #2846

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sqlmesh/dbt/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import logging
import os
import re
import typing as t
from argparse import Namespace
Expand Down Expand Up @@ -260,6 +261,11 @@ def _load_manifest(self) -> Manifest:
)
flags.set_from_args(args, None)

if DBT_VERSION >= (1, 8):
from dbt_common.context import set_invocation_context # type: ignore

set_invocation_context(os.environ)

profile = self._load_profile()
project = self._load_project(profile)

Expand All @@ -274,10 +280,8 @@ def _load_manifest(self) -> Manifest:

if DBT_VERSION >= (1, 8):
from dbt.mp_context import get_mp_context # type: ignore
from dbt_common.context import set_invocation_context # type: ignore

register_adapter(runtime_config, get_mp_context()) # type: ignore
set_invocation_context({})
else:
register_adapter(runtime_config) # type: ignore

Expand Down