Skip to content

Commit

Permalink
add config.project_dir()
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-schick committed Jan 23, 2023
1 parent 93f8bdd commit 439e116
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions mara_dbt/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def shell_command(self):
variables.update(self.variables)

return (f'dbt --no-use-colors {self._dbt_command}'
+ (f' --project-dir {config.project_dir()}' if config.project_dir() else '')
+ (f' --profiles-dir {config.profiles_dir()}' if config.profiles_dir() else '')
+ (f' --profile {config.profile()}' if config.profile() else '')
+ (f' -t {self.target}' if self.target else '')
Expand Down
24 changes: 17 additions & 7 deletions mara_dbt/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pathlib
import os
from typing import Optional


def dbt_target() -> str:
def dbt_target() -> Optional[str]:
"""
The dbt default target to be used.
Expand All @@ -24,21 +26,21 @@ def dbt_variables() -> dict:
return {}


def dbt_cloud_host() -> str:
def dbt_cloud_host() -> Optional[str]:
"""
dbt Cloud host (cloud.getdbt.com (multi-tenant instance) by default if the environment variable is not set)
"""
return None


def dbt_cloud_api_token() -> str:
def dbt_cloud_api_token() -> Optional[str]:
"""
API authentication key
"""
return None


def dbt_cloud_account_id() -> str:
def dbt_cloud_account_id() -> Optional[str]:
"""
Numeric ID of the dbt Cloud account
"""
Expand All @@ -49,20 +51,28 @@ def dbt_cloud_account_id() -> str:
# Advanced config
# -----------------------------------------------------------------------------

def profiles_dir() -> str:
def profiles_dir() -> Optional[str]:
""" The folder in which the dbt profiles are saved. If None, ~/.dbt/ is used (dbt default) """
return None

def profile() -> str:

def profile() -> Optional[str]:
""" Which dbt profile to use. If not set the default profile will be used """
return None


def project_dir() -> Optional[str]:
""" If a custom project path shall be used. This is read from environment variable DBT_PROJECT_DIR. """
# Use env. to support https://github.com/dbt-labs/dbt-core/issues/6078. Can be dropped when minimum
# dbt version for this module is a version which supports dbt-core#6078.
return os.environ.get('DBT_PROJECT_DIR')


# -----------------------------------------------------------------------------
# Experimental, building dbt via the mara project
# -----------------------------------------------------------------------------

def schema_name() -> str:
def schema_name() -> Optional[str]:
""" The schema name which shall be used in the config. If not set, the default db schema will be used. """
return None

Expand Down

0 comments on commit 439e116

Please sign in to comment.