Skip to content

Commit 61a934f

Browse files
committed
WIP
1 parent 419f440 commit 61a934f

2 files changed

Lines changed: 16 additions & 31 deletions

File tree

src/dbt_core_interface/dbt_templater/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
"""Defines the hook endpoints for the dbt templater plugin."""
2+
23
import logging
34

45
from sqlfluff.core.plugin import hookimpl
56

67
from dbt_core_interface.dbt_templater.templater import DCIDbtTemplater
78

8-
99
LOGGER = logging.getLogger(__name__)
1010

1111

1212
@hookimpl
1313
def get_templaters():
1414
"""Get templaters."""
15+
1516
def create_templater(**kwargs):
1617
import dbt_core_interface.state
17-
assert dbt_core_interface.state.dbt_project_container is not None, "dbt_project_container is None"
18+
19+
assert dbt_core_interface.state.dbt_project_container is not None, (
20+
"dbt_project_container is None"
21+
)
1822
return DCIDbtTemplater(
19-
dbt_project_container=dbt_core_interface.state.dbt_project_container,
20-
**kwargs
23+
dbt_project_container=dbt_core_interface.state.dbt_project_container, **kwargs
2124
)
2225

2326
create_templater.name = DCIDbtTemplater.name

src/dbt_core_interface/project.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class DbtConfiguration:
7575
profiles_dir: str = DEFAULT_PROFILES_DIR
7676
target: str | None = None
7777
threads: int = 1
78-
vars: dict[str, t.Any] = {}
78+
vars: dict[str, t.Any] = field(default_factory=dict)
79+
profile: str | None = None
7980

8081
single_threaded: bool = True
8182
quiet: bool = True
@@ -84,7 +85,7 @@ class DbtConfiguration:
8485
partial_parse: bool = False
8586

8687
dependencies: list[str] = field(default_factory=list)
87-
which: str = "cupertino"
88+
which: str = "zezima was here"
8889
REQUIRE_RESOURCE_NAMES_WITHOUT_SPACES: bool = field(default_factory=bool)
8990

9091
def __post_init__(self) -> None:
@@ -237,33 +238,14 @@ def _initialize_adapter(self) -> None:
237238
self._adapter.debug_query()
238239

239240
logger.debug(f"Initialized adapter for {self.project_name}")
240-
self.runtime_config.adapter = self.adapter # pyright: ignore[reportAttributeAccessIssue]
241+
self.runtime_config.adapter = self._adapter # pyright: ignore[reportAttributeAccessIssue]
241242

242243
def _parse_project(self, write_manifest: bool = True) -> None:
243244
"""Parse the dbt project and load manifest."""
244-
set_from_args(
245-
argparse.Namespace(
246-
target=self._base_params.target,
247-
profiles_dir=self._base_params.profiles_dir,
248-
project_dir=self._base_params.project_dir,
249-
threads=self._base_params.threads,
250-
vars=self._base_params.vars,
251-
quiet=True,
252-
single_threaded=True,
253-
),
254-
None,
255-
)
245+
set_from_args(self._base_params, None)
256246

257247
with self._manifest_lock:
258-
self._runtime_config = RuntimeConfig.from_args(
259-
argparse.Namespace(
260-
target=self._base_params.target,
261-
profiles_dir=self._base_params.profiles_dir,
262-
project_dir=self._base_params.project_dir,
263-
threads=self._base_params.threads,
264-
vars=self._base_params.vars,
265-
)
266-
)
248+
self._runtime_config = RuntimeConfig.from_args(self._base_params)
267249

268250
manifest_loader = ManifestLoader(
269251
self._runtime_config,
@@ -313,7 +295,7 @@ def generate_runtime_model_context(self, node: ManifestNode) -> dict[str, t.Any]
313295
self.manifest,
314296
)
315297

316-
def get_ref_node(
298+
def ref(
317299
self,
318300
model_name: str,
319301
target_package: str | None = None,
@@ -332,7 +314,7 @@ def get_ref_node(
332314
if node:
333315
return node
334316

335-
def get_source_node(self, source_name: str, table_name: str) -> SourceDefinition | None:
317+
def source(self, source_name: str, table_name: str) -> SourceDefinition | None:
336318
"""Get source node by source and table name."""
337319
return self.manifest.source_lookup.find(f"{source_name}.{table_name}", None, self.manifest)
338320

@@ -409,7 +391,7 @@ def _create_temp_node(
409391

410392
def _cleanup() -> None:
411393
with contextlib.suppress(KeyError):
412-
del self.manifest.nodes[node_id]
394+
del self.manifest.nodes[sql_node.unique_id]
413395

414396
return sql_node, _cleanup
415397

0 commit comments

Comments
 (0)