Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

fix(dbt-fal): reconstructing the adapter #823

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion projects/adapter/src/dbt/adapters/fal/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dbt.config.profile import Profile
from dbt.adapters.base.impl import BaseAdapter, BaseRelation
from dbt.adapters.factory import FACTORY
from dbt.adapters.fal_experimental.adapter import IS_RECONSTRUCTED

# TODO: offer in `from isolate import is_agent`
from isolate.connections.common import is_agent
Expand Down Expand Up @@ -96,7 +97,7 @@ def load_profiles_info() -> Tuple[Profile, Dict[str, bool], Dict[str, bool]]:
INHERIT_PROPERTIES = defaultdict(lambda: True)

# NOTE: Should this file run on isolate agents? Could we skip it entirely and build a FalEncAdapterWrapper directly?
if not is_agent():
if not IS_RECONSTRUCTED:
DB_PROFILE, PROFILE_PROPERTIES, ARGS_PROPERTIES = load_profiles_info()
DB_RELATION = FACTORY.get_relation_class_by_name(DB_PROFILE.credentials.type)

Expand Down
6 changes: 6 additions & 0 deletions projects/adapter/src/dbt/adapters/fal_experimental/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

from .utils import extra_path, get_fal_scripts_path, retrieve_symbol

IS_RECONSTRUCTED = False


def run_with_adapter(code: str, adapter: BaseAdapter, config: RuntimeConfig) -> Any:
# main symbol is defined during dbt-fal's compilation
Expand All @@ -50,6 +52,10 @@ def _isolated_runner(
# This function can be run in an entirely separate
# process or an environment, so we need to reconstruct
# the DB adapter solely from the config.
global IS_RECONSTRUCTED
IS_RECONSTRUCTED = True
from .adapter_support import reconstruct_adapter

adapter = reconstruct_adapter(config, manifest, macro_manifest)
fal_scripts_path = get_fal_scripts_path(config)
if local_packages is not None:
Expand Down