Skip to content
Merged
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
23 changes: 23 additions & 0 deletions elementary/monitor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from elementary.monitor.data_monitoring.report.data_monitoring_report import (
DataMonitoringReport,
)
from elementary.monitor.debug import Debug
from elementary.tracking.anonymous_tracking import AnonymousCommandLineTracking
from elementary.utils import bucket_path
from elementary.utils.ordered_yaml import OrderedYaml
Expand All @@ -20,6 +21,7 @@ class Command:
MONITOR = "monitor"
REPORT = "monitor-report"
SEND_REPORT = "monitor-send-report"
DEBUG = "debug"


# Displayed in reverse order in --help.
Expand Down Expand Up @@ -599,5 +601,26 @@ def send_report(
raise


@monitor.command()
@click.option(
"--profiles-dir",
"-p",
type=click.Path(exists=True),
default=None,
help="Which directory to look in for the profiles.yml file. "
"If not set, edr will look in the current working directory first, then HOME/.dbt/",
)
@click.pass_context
def debug(ctx, profiles_dir):
config = Config(profiles_dir=profiles_dir)
anonymous_tracking = AnonymousCommandLineTracking(config)
anonymous_tracking.track_cli_start(Command.DEBUG, None, ctx.command.name)
success = Debug(config).run()
if not success:
sys.exit(1)

anonymous_tracking.track_cli_end(Command.DEBUG, None, ctx.command.name)


if __name__ == "__main__":
monitor()
29 changes: 29 additions & 0 deletions elementary/monitor/debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import click

from elementary.clients.dbt.dbt_runner import DbtRunner
from elementary.config.config import Config
from elementary.exceptions.exceptions import DbtCommandError
from elementary.monitor import dbt_project_utils


class Debug:
def __init__(self, config: Config):
self.config = config

def run(self) -> bool:
dbt_runner = DbtRunner(
dbt_project_utils.PATH,
self.config.profiles_dir,
self.config.profile_target,
)

try:
dbt_runner.run_operation("test_conn", quiet=True)
except DbtCommandError as err:
click.echo(
f"Could not connect to the Elementary db and schema. See details below\n\n{err}"
)
return False

click.echo("Connected to the Elementary db and schema successfully")
return True