-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
378 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from .manifest import Manifest | ||
from .profile import Profile | ||
from .credentials import Credentials | ||
from .project import Project | ||
from .result import Result | ||
from .run_results import RunResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
|
||
@dataclass | ||
class CliArgs: | ||
project_dir: Path | ||
profiles_dir: Path | ||
profile: Optional[str] | ||
target: Optional[str] | ||
threads: Optional[int] | ||
vars: Optional[dict[str, str]] | ||
|
||
|
||
@dataclass | ||
class FlagsArgs: | ||
project_dir: Path | ||
profiles_dir: Path | ||
profile: Optional[str] = None | ||
target: Optional[str] = None | ||
vars: Optional[dict[str, str]] = None | ||
use_colors: Optional[bool] = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from dbt.config.runtime import RuntimeConfig | ||
|
||
from odd_dbt.domain import Manifest, Credentials, RunResults | ||
from odd_dbt.domain.cli_args import CliArgs | ||
from odd_dbt.errors import DbtInternalError | ||
from odd_dbt.utils import load_json | ||
|
||
|
||
class DbtContext: | ||
def __init__(self, cli_args: CliArgs): | ||
try: | ||
self._config = RuntimeConfig.from_args(cli_args) | ||
self.target_path = cli_args.project_dir / self._config.target_path | ||
except Exception as e: | ||
raise DbtInternalError(f"Failed getting dbt context: {e}") from e | ||
|
||
@property | ||
def adapter_type(self) -> str: | ||
return self._config.get_metadata().adapter_type | ||
|
||
@property | ||
def catalog(self): | ||
if (catalog := self.target_path / "catalog.json").is_file(): | ||
return load_json(catalog) | ||
|
||
return None | ||
|
||
@property | ||
def credentials(self) -> Credentials: | ||
return Credentials(**self._config.credentials.to_dict()) | ||
|
||
@property | ||
def manifest(self) -> Manifest: | ||
return Manifest(self.target_path / "manifest.json") | ||
|
||
@property | ||
def run_results(self) -> RunResults: | ||
return RunResults(self.target_path / "run_results.json") | ||
|
||
@property | ||
def results(self) -> list[dict]: | ||
return self.run_results.results | ||
|
||
@property | ||
def invocation_id(self) -> str: | ||
return self.run_results.invocation_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Credentials: | ||
def __init__(self, **config) -> None: | ||
del config["password"] | ||
self._config: dict[str, str] = config | ||
|
||
def __getitem__(self, item): | ||
return self._config.get(item) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from odd_models.logger import logger | ||
from odd_models.logger import logger | ||
|
||
logger = logger |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.