Skip to content

Commit d282c53

Browse files
committed
add config name support
1 parent 78bd444 commit d282c53

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

src/datapilot/clients/altimate/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,9 @@ def run_project_governance_llm_checks(self, manifest, catalog, check_names):
104104
"check_names": check_names,
105105
}
106106
return self.post(endpoint, data=data)
107+
108+
def get_all_dbt_configs(self):
109+
"""Get all DBT configs with a page size of 100."""
110+
endpoint = "/dbt/v1/configs"
111+
params = {"size": 100}
112+
return self.get(endpoint, params=params)

src/datapilot/clients/altimate/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,13 @@ def run_project_governance_llm_checks(
124124
):
125125
api_client = APIClient(api_token=api_token, base_url=backend_url, tenant=tenant)
126126
return api_client.run_project_governance_llm_checks(manifest, catalog, check_names)
127+
128+
129+
def get_all_dbt_configs(
130+
api_token,
131+
tenant,
132+
backend_url,
133+
):
134+
"""Get all DBT configs from the API."""
135+
api_client = APIClient(api_token=api_token, base_url=backend_url, tenant=tenant)
136+
return api_client.get_all_dbt_configs()

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import click
44

55
from datapilot.clients.altimate.utils import check_token_and_instance
6+
from datapilot.clients.altimate.utils import get_all_dbt_configs
67
from datapilot.clients.altimate.utils import onboard_file
78
from datapilot.clients.altimate.utils import start_dbt_ingestion
89
from datapilot.clients.altimate.utils import validate_credentials
@@ -45,6 +46,11 @@ def dbt():
4546
required=False,
4647
help="Path to the DBT config file",
4748
)
49+
@click.option(
50+
"--config-name",
51+
required=False,
52+
help="Name of the DBT config to use from the API",
53+
)
4854
@click.option(
4955
"--select",
5056
required=False,
@@ -53,7 +59,14 @@ def dbt():
5359
)
5460
@click.option("--backend-url", required=False, help="Altimate's Backend URL", default="https://api.myaltimate.com")
5561
def project_health(
56-
token, instance_name, manifest_path, catalog_path, config_path=None, select=None, backend_url="https://api.myaltimate.com"
62+
token,
63+
instance_name,
64+
manifest_path,
65+
catalog_path,
66+
config_path=None,
67+
config_name=None,
68+
select=None,
69+
backend_url="https://api.myaltimate.com",
5770
):
5871
"""
5972
Validate the DBT project's configuration and structure.
@@ -62,6 +75,22 @@ def project_health(
6275
config = None
6376
if config_path:
6477
config = load_config(config_path)
78+
elif config_name and token and instance_name:
79+
# Get configs from API
80+
configs = get_all_dbt_configs(token, instance_name, backend_url)
81+
if configs and "items" in configs:
82+
# Find config by name
83+
matching_configs = [c for c in configs["items"] if c["name"] == config_name]
84+
if matching_configs:
85+
# Get the config directly from the API response
86+
config = matching_configs[0].get("config", {})
87+
else:
88+
click.echo(f"No config found with name: {config_name}")
89+
return
90+
else:
91+
click.echo("Failed to fetch configs from API")
92+
return
93+
6594
selected_models = []
6695
if select:
6796
selected_models = select.split(" ")

0 commit comments

Comments
 (0)