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

Commit

Permalink
refact(dbt-fal): better handling of reconstructed adapter env
Browse files Browse the repository at this point in the history
  • Loading branch information
mederka committed Apr 14, 2023
1 parent a8271bd commit 0fd6c13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit 0fd6c13

Please sign in to comment.