Skip to content

Commit 54ba983

Browse files
committed
changes
1 parent c18defa commit 54ba983

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

src/datapilot/core/platforms/dbt/cli/cli.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
import click
44

55
from datapilot.clients.altimate.utils import check_token_and_instance
6-
from datapilot.clients.altimate.utils import get_project_governance_llm_checks
76
from datapilot.clients.altimate.utils import onboard_file
8-
from datapilot.clients.altimate.utils import run_project_governance_llm_checks
97
from datapilot.clients.altimate.utils import start_dbt_ingestion
108
from datapilot.clients.altimate.utils import validate_credentials
119
from datapilot.clients.altimate.utils import validate_permissions
1210
from datapilot.config.config import load_config
11+
from datapilot.core.platforms.dbt.constants import LLM
1312
from datapilot.core.platforms.dbt.constants import MODEL
1413
from datapilot.core.platforms.dbt.constants import PROJECT
1514
from datapilot.core.platforms.dbt.executor import DBTInsightGenerator
@@ -30,8 +29,8 @@ def dbt():
3029

3130

3231
@dbt.command("project-health")
33-
@click.option("--token", prompt="API Token", help="Your API token for authentication.")
34-
@click.option("--instance-name", prompt="Instance Name", help="Your tenant ID.")
32+
@click.option("--token", required=False, prompt="API Token", help="Your API token for authentication.")
33+
@click.option("--instance-name", required=False, prompt="Instance Name", help="Your tenant ID.")
3534
@click.option(
3635
"--manifest-path",
3736
required=True,
@@ -70,15 +69,20 @@ def project_health(
7069
manifest = load_manifest(manifest_path)
7170
catalog = load_catalog(catalog_path) if catalog_path else None
7271

73-
llm_checks = get_project_governance_llm_checks(token, instance_name, backend_url)
74-
check_names = [check["name"] for check in llm_checks if check["alias"] not in config.get("disabled_insights", [])]
75-
llm_check_results = run_project_governance_llm_checks(token, instance_name, backend_url, manifest, catalog, check_names)
76-
77-
insight_generator = DBTInsightGenerator(manifest=manifest, catalog=catalog, config=config, selected_models=selected_models)
72+
insight_generator = DBTInsightGenerator(
73+
manifest=manifest,
74+
catalog=catalog,
75+
config=config,
76+
selected_models=selected_models,
77+
token=token,
78+
instance_name=instance_name,
79+
backend_url=backend_url,
80+
)
7881
reports = insight_generator.run()
7982

8083
package_insights = reports[PROJECT]
8184
model_insights = reports[MODEL]
85+
llm_insights = reports[LLM]
8286
model_report = generate_model_insights_table(model_insights)
8387
if len(model_report) > 0:
8488
click.echo("--" * 50)
@@ -97,11 +101,11 @@ def project_health(
97101
click.echo("--" * 50)
98102
click.echo(tabulate_data(project_report, headers="keys"))
99103

100-
if llm_check_results:
104+
if len(llm_insights):
101105
click.echo("--" * 50)
102106
click.echo("Project Governance LLM Insights")
103107
click.echo("--" * 50)
104-
for check in llm_check_results["results"]:
108+
for check in llm_insights:
105109
click.echo(f"Check: {check['name']}")
106110
for answer in check["answer"]:
107111
click.echo(f"Rule: {answer['Rule']}")

src/datapilot/core/platforms/dbt/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
MODEL = "model"
55
SOURCE = "source"
66

7+
LLM = "llm"
8+
79

810
PROJECT = "project"
911
SQL = "sql"

src/datapilot/core/platforms/dbt/executor.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
from typing import List
66
from typing import Optional
77

8+
from datapilot.clients.altimate.utils import get_project_governance_llm_checks
9+
from datapilot.clients.altimate.utils import run_project_governance_llm_checks
10+
from datapilot.core.platforms.dbt.constants import LLM
811
from datapilot.core.platforms.dbt.constants import MODEL
912
from datapilot.core.platforms.dbt.constants import PROJECT
1013
from datapilot.core.platforms.dbt.exceptions import AltimateCLIArgumentError
@@ -29,11 +32,17 @@ def __init__(
2932
target: str = "dev",
3033
selected_models: Optional[str] = None,
3134
selected_model_ids: Optional[List[str]] = None,
35+
token: Optional[str] = None,
36+
instance_name: Optional[str] = None,
37+
backend_url: Optional[str] = None,
3238
):
3339
self.run_results_path = run_results_path
3440
self.target = target
3541
self.env = env
3642
self.config = config or {}
43+
self.token = token
44+
self.instance_name = instance_name
45+
self.backend_url = backend_url
3746

3847
self.manifest_wrapper = DBTFactory.get_manifest_wrapper(manifest)
3948
self.manifest_present = True
@@ -85,10 +94,19 @@ def _check_if_skipped(self, insight):
8594
return True
8695
return False
8796

97+
def run_llm_checks(self):
98+
llm_checks = get_project_governance_llm_checks(self.token, self.instance_name, self.backend_url)
99+
check_names = [check["name"] for check in llm_checks if check["alias"] not in self.config.get("disabled_insights", [])]
100+
llm_check_results = run_project_governance_llm_checks(
101+
self.token, self.instance_name, self.backend_url, self.manifest, self.catalog, check_names
102+
)
103+
return llm_check_results
104+
88105
def run(self):
89106
reports = {
90107
MODEL: {},
91108
PROJECT: [],
109+
LLM: [],
92110
}
93111
for insight_class in INSIGHTS:
94112
# TODO: Skip insight based on config
@@ -154,4 +172,9 @@ def run(self):
154172
else:
155173
self.logger.info(color_text(f"Skipping insight {insight_class.NAME} as {message}", YELLOW))
156174

175+
if self.token and self.instance_name and self.backend_url:
176+
llm_check_results = self.run_llm_checks()
177+
if llm_check_results:
178+
reports[LLM].extend(llm_check_results["results"])
179+
157180
return reports

0 commit comments

Comments
 (0)