Skip to content

Commit c18defa

Browse files
committed
project governance llm checks
1 parent f20c81b commit c18defa

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

src/datapilot/clients/altimate/client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,16 @@ def validate_upload_to_integration(self):
9191
def start_dbt_ingestion(self, params=None):
9292
endpoint = "/dbt/v1/start_dbt_ingestion"
9393
return self.post(endpoint, data=params)
94+
95+
def get_project_governance_llm_checks(self, params=None):
96+
endpoint = "/project_governance/checks"
97+
return self.get(endpoint, params=params)
98+
99+
def run_project_governance_llm_checks(self, manifest, catalog, check_names):
100+
endpoint = "/project_governance/run_checks"
101+
data = {
102+
"manifest": manifest,
103+
"catalog": catalog,
104+
"check_names": check_names,
105+
}
106+
return self.post(endpoint, data=data)

src/datapilot/clients/altimate/utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,24 @@ def start_dbt_ingestion(api_token, tenant, dbt_core_integration_id, dbt_core_int
103103
"ok": False,
104104
"message": "Error starting dbt ingestion worker. ",
105105
}
106+
107+
108+
def get_project_governance_llm_checks(
109+
api_token,
110+
tenant,
111+
backend_url,
112+
):
113+
api_client = APIClient(api_token=api_token, base_url=backend_url, tenant=tenant)
114+
return api_client.get_project_governance_llm_checks()
115+
116+
117+
def run_project_governance_llm_checks(
118+
api_token,
119+
tenant,
120+
backend_url,
121+
manifest,
122+
catalog,
123+
check_names,
124+
):
125+
api_client = APIClient(api_token=api_token, base_url=backend_url, tenant=tenant)
126+
return api_client.run_project_governance_llm_checks(manifest, catalog, check_names)

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
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
67
from datapilot.clients.altimate.utils import onboard_file
8+
from datapilot.clients.altimate.utils import run_project_governance_llm_checks
79
from datapilot.clients.altimate.utils import start_dbt_ingestion
810
from datapilot.clients.altimate.utils import validate_credentials
911
from datapilot.clients.altimate.utils import validate_permissions
@@ -28,6 +30,8 @@ def dbt():
2830

2931

3032
@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.")
3135
@click.option(
3236
"--manifest-path",
3337
required=True,
@@ -49,7 +53,10 @@ def dbt():
4953
default=None,
5054
help="Selective model testing. Specify one or more models to run tests on.",
5155
)
52-
def project_health(manifest_path, catalog_path, config_path=None, select=None):
56+
@click.option("--backend-url", required=False, help="Altimate's Backend URL", default="https://api.myaltimate.com")
57+
def project_health(
58+
token, instance_name, manifest_path, catalog_path, config_path=None, select=None, backend_url="https://api.myaltimate.com"
59+
):
5360
"""
5461
Validate the DBT project's configuration and structure.
5562
:param manifest_path: Path to the DBT manifest file.
@@ -62,6 +69,11 @@ def project_health(manifest_path, catalog_path, config_path=None, select=None):
6269
selected_models = select.split(" ")
6370
manifest = load_manifest(manifest_path)
6471
catalog = load_catalog(catalog_path) if catalog_path else None
72+
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+
6577
insight_generator = DBTInsightGenerator(manifest=manifest, catalog=catalog, config=config, selected_models=selected_models)
6678
reports = insight_generator.run()
6779

@@ -85,6 +97,19 @@ def project_health(manifest_path, catalog_path, config_path=None, select=None):
8597
click.echo("--" * 50)
8698
click.echo(tabulate_data(project_report, headers="keys"))
8799

100+
if llm_check_results:
101+
click.echo("--" * 50)
102+
click.echo("Project Governance LLM Insights")
103+
click.echo("--" * 50)
104+
for check in llm_check_results["results"]:
105+
click.echo(f"Check: {check['name']}")
106+
for answer in check["answer"]:
107+
click.echo(f"Rule: {answer['Rule']}")
108+
click.echo(f"Location: {answer['Location']}")
109+
click.echo(f"Issue: {answer['Issue']}")
110+
click.echo(f"Fix: {answer['Fix']}")
111+
click.echo("\n")
112+
88113

89114
@dbt.command("onboard")
90115
@click.option("--token", prompt="API Token", help="Your API token for authentication.")

0 commit comments

Comments
 (0)