altimate-datapilot-cli 0.0.10__py3-none-any.whl → 0.0.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: altimate-datapilot-cli
3
- Version: 0.0.10
3
+ Version: 0.0.12
4
4
  Summary: Assistant for Data Teams
5
5
  Home-page: https://github.com/AltimateAI/datapilot-cli
6
6
  Author: Altimate Inc
@@ -31,7 +31,6 @@ Requires-Python: >=3.8
31
31
  License-File: LICENSE
32
32
  License-File: AUTHORS.rst
33
33
  Requires-Dist: click (==8.1.7)
34
- Requires-Dist: sqlglot (==18.3.0)
35
34
  Requires-Dist: dbt-artifacts-parser (==0.5.1)
36
35
  Requires-Dist: ruamel.yaml (==0.18.6)
37
36
  Requires-Dist: tabulate (==0.9.0)
@@ -1,11 +1,11 @@
1
- datapilot/__init__.py,sha256=-nNlMKS9nph3FR78_ZG9RGKrbxseeNp2K6nMr0pVGaU,23
1
+ datapilot/__init__.py,sha256=1SFj-qMOaeO0fOKQaFmYhAKiRwwNda5uWKpYtIcken8,23
2
2
  datapilot/__main__.py,sha256=I9USmeNnK-cAHb6LZfydJC0LeNSE8enieeY55wpR6uw,380
3
3
  datapilot/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  datapilot/cli/main.py,sha256=VSdqlkCiu8GSG9qQh8q0BzyocsQc4lKWxZAPEsjXF18,181
5
5
  datapilot/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  datapilot/clients/altimate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- datapilot/clients/altimate/client.py,sha256=ayTvegsQKOj0EocIWeB03ys1PlGLJFB5k8zDs8oxPBo,3107
8
- datapilot/clients/altimate/utils.py,sha256=cDYR-6J4SDaOBMOtkOlaP_j0TkCgCyYLFVDjVCEiCLY,2629
7
+ datapilot/clients/altimate/client.py,sha256=DHPG2y7r1gFph80TVp7zozd_Hl05mzxtNFQ4JYEN1Jk,3260
8
+ datapilot/clients/altimate/utils.py,sha256=IyS4iY5nE5KF9bivHKVzioUitQnmgVVIZjqPNFoeUwY,3547
9
9
  datapilot/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  datapilot/config/config.py,sha256=kyj53Qsb85V4iGQsX0vSwULOjscMOSFrJDJ3tnagJpo,403
11
11
  datapilot/config/utils.py,sha256=DIAVX-OZ5Lc0Ky_A7dvdbPcD1QSg2DRxZcuaIIZ2rhw,1146
@@ -30,7 +30,7 @@ datapilot/core/platforms/dbt/factory.py,sha256=fsk8XWXiSq22t5BH5jGQMASWIJ-eUNqOh
30
30
  datapilot/core/platforms/dbt/formatting.py,sha256=bpfa7XmVghTq4WnGDGYC6DruwOwH8YmjFHghoo5cPD8,1638
31
31
  datapilot/core/platforms/dbt/utils.py,sha256=ozFHprR6LTLXQdrGyaRoyIBTua4P1NkP8T7LGgN-9c0,18577
32
32
  datapilot/core/platforms/dbt/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
- datapilot/core/platforms/dbt/cli/cli.py,sha256=sEPOoYL7lVy4G5Y4HNi6yeQqMtknxIh1EzobiisBL6c,4146
33
+ datapilot/core/platforms/dbt/cli/cli.py,sha256=qzeJU8ALoo-VykKeqPT0O5pheMMH9noBh7S42099p7w,5563
34
34
  datapilot/core/platforms/dbt/hooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  datapilot/core/platforms/dbt/hooks/executor_hook.py,sha256=gSM50vAO7C-f1rdnHogWbqc87aCXPXysZepjp5L2qzw,2966
36
36
  datapilot/core/platforms/dbt/insights/__init__.py,sha256=vnNOqP6lJ-r1SqmxQbeTEphL-omj466OanqQY1WNrUA,7547
@@ -130,13 +130,13 @@ datapilot/schemas/constants.py,sha256=-eyLQvpB3ut2cQ8Cx-xGpCa9lOHBUATA8s-FXEkBoF
130
130
  datapilot/schemas/nodes.py,sha256=bm2ui0rx46UTzlI-Fbvh0BkGWNqnUBPBz-uNL5XAzPI,319
131
131
  datapilot/schemas/sql.py,sha256=swvQKX0E2t9K48zB7NiqmPl8yZgfzILMHwBdzAwe1hQ,193
132
132
  datapilot/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
133
- datapilot/utils/utils.py,sha256=XGi0jn030M2Cp_WJ-cIOZzdzRewEOQrPldzcaDj7uPw,11150
133
+ datapilot/utils/utils.py,sha256=MY8q6ZBJ0hkrTuH7gWMxAlEAQGrajXFMabEhtGtT7sc,11524
134
134
  datapilot/utils/formatting/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
135
135
  datapilot/utils/formatting/utils.py,sha256=rAVmIYuldvw9VvCSwG2kMTEgiT7cEconp_F1sAWVyCo,1377
136
- altimate_datapilot_cli-0.0.10.dist-info/AUTHORS.rst,sha256=S4H4zw_v3GVyz5_55jF5Gf_YNG3s5Y0VgbQaEov9PFk,50
137
- altimate_datapilot_cli-0.0.10.dist-info/LICENSE,sha256=Mf7VqpsmU2QR5_s2Cb_ZeeMB2Q9KW7YXJENZPFZRK1k,1100
138
- altimate_datapilot_cli-0.0.10.dist-info/METADATA,sha256=sVAlnm0mvyJ-cSbcc25WA14HNwuWZp5myRiUXDJ3Dc8,2399
139
- altimate_datapilot_cli-0.0.10.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
140
- altimate_datapilot_cli-0.0.10.dist-info/entry_points.txt,sha256=0zwgKxN40RLVB5jSmlJz7IH_FBqRtpFdbrdZn-xuQIY,141
141
- altimate_datapilot_cli-0.0.10.dist-info/top_level.txt,sha256=gAOFOdwB00vcxv74y4M1J-nQtPvEatU8-mYViEBcToo,10
142
- altimate_datapilot_cli-0.0.10.dist-info/RECORD,,
136
+ altimate_datapilot_cli-0.0.12.dist-info/AUTHORS.rst,sha256=S4H4zw_v3GVyz5_55jF5Gf_YNG3s5Y0VgbQaEov9PFk,50
137
+ altimate_datapilot_cli-0.0.12.dist-info/LICENSE,sha256=Mf7VqpsmU2QR5_s2Cb_ZeeMB2Q9KW7YXJENZPFZRK1k,1100
138
+ altimate_datapilot_cli-0.0.12.dist-info/METADATA,sha256=XCKSmeQwcKzUJqlhoa9F3wsArWyp2FYUSZoJow4R2yk,2365
139
+ altimate_datapilot_cli-0.0.12.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
140
+ altimate_datapilot_cli-0.0.12.dist-info/entry_points.txt,sha256=0zwgKxN40RLVB5jSmlJz7IH_FBqRtpFdbrdZn-xuQIY,141
141
+ altimate_datapilot_cli-0.0.12.dist-info/top_level.txt,sha256=gAOFOdwB00vcxv74y4M1J-nQtPvEatU8-mYViEBcToo,10
142
+ altimate_datapilot_cli-0.0.12.dist-info/RECORD,,
datapilot/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.10"
1
+ __version__ = "0.0.12"
@@ -62,7 +62,7 @@ class APIClient:
62
62
  response = requests.post(url, headers=headers, json=data, timeout=timeout)
63
63
  self.logger.debug(f"Received POST response with status: {response.status_code }")
64
64
 
65
- return response
65
+ return response.json()
66
66
 
67
67
  def put(self, endpoint, data, timeout=None):
68
68
  url = f"{self.base_url}{endpoint}"
@@ -83,3 +83,7 @@ class APIClient:
83
83
  def validate_credentials(self):
84
84
  endpoint = "/dbt/v3/validate-credentials"
85
85
  return self.get(endpoint)
86
+
87
+ def start_dbt_ingestion(self, params=None):
88
+ endpoint = "/dbt/v1/start_dbt_ingestion"
89
+ return self.post(endpoint, data=params)
@@ -46,10 +46,14 @@ def validate_credentials(
46
46
  return api_client.validate_credentials()
47
47
 
48
48
 
49
- def onboard_manifest(api_token, tenant, dbt_core_integration_id, manifest_path, backend_url) -> Dict:
49
+ def onboard_file(api_token, tenant, dbt_core_integration_id, dbt_core_integration_environment, file_type, file_path, backend_url) -> Dict:
50
50
  api_client = APIClient(api_token, base_url=backend_url, tenant=tenant)
51
51
 
52
- params = {"dbt_core_integration_id": dbt_core_integration_id, "file_type": "manifest"}
52
+ params = {
53
+ "dbt_core_integration_id": dbt_core_integration_id,
54
+ "dbt_core_integration_environment_type": dbt_core_integration_environment,
55
+ "file_type": file_type,
56
+ }
53
57
  signed_url_data = api_client.get_signed_url(params)
54
58
  if signed_url_data:
55
59
  signed_url = signed_url_data.get("url")
@@ -57,7 +61,7 @@ def onboard_manifest(api_token, tenant, dbt_core_integration_id, manifest_path,
57
61
  api_client.log(f"Received signed URL: {signed_url}")
58
62
  api_client.log(f"Received File ID: {file_id}")
59
63
 
60
- upload_response = upload_content_to_signed_url(manifest_path, signed_url)
64
+ upload_response = upload_content_to_signed_url(file_path, signed_url)
61
65
 
62
66
  if upload_response:
63
67
  verify_params = {"dbt_core_integration_file_id": file_id}
@@ -73,3 +77,20 @@ def onboard_manifest(api_token, tenant, dbt_core_integration_id, manifest_path,
73
77
  "ok": False,
74
78
  "message": "Error in uploading the manifest. ",
75
79
  }
80
+
81
+
82
+ def start_dbt_ingestion(api_token, tenant, dbt_core_integration_id, dbt_core_integration_environment, backend_url):
83
+ api_client = APIClient(api_token, base_url=backend_url, tenant=tenant)
84
+ params = {
85
+ "dbt_core_integration_id": dbt_core_integration_id,
86
+ "dbt_core_integration_environment_type": dbt_core_integration_environment,
87
+ }
88
+ data = api_client.start_dbt_ingestion(params)
89
+ if data and data.get("ok"):
90
+ return {"ok": True}
91
+ else:
92
+ api_client.log("Error starting dbt ingestion worker")
93
+ return {
94
+ "ok": False,
95
+ "message": "Error starting dbt ingestion worker. ",
96
+ }
@@ -3,7 +3,8 @@ import logging
3
3
  import click
4
4
 
5
5
  from datapilot.clients.altimate.utils import check_token_and_instance
6
- from datapilot.clients.altimate.utils import onboard_manifest
6
+ from datapilot.clients.altimate.utils import onboard_file
7
+ from datapilot.clients.altimate.utils import start_dbt_ingestion
7
8
  from datapilot.clients.altimate.utils import validate_credentials
8
9
  from datapilot.config.config import load_config
9
10
  from datapilot.core.platforms.dbt.constants import MODEL
@@ -14,6 +15,7 @@ from datapilot.core.platforms.dbt.formatting import generate_project_insights_ta
14
15
  from datapilot.core.platforms.dbt.utils import load_catalog
15
16
  from datapilot.core.platforms.dbt.utils import load_manifest
16
17
  from datapilot.utils.formatting.utils import tabulate_data
18
+ from datapilot.utils.utils import map_url_to_instance
17
19
 
18
20
  logging.basicConfig(level=logging.INFO)
19
21
 
@@ -87,9 +89,21 @@ def project_health(manifest_path, catalog_path, config_path=None, select=None):
87
89
  @click.option("--token", prompt="API Token", help="Your API token for authentication.")
88
90
  @click.option("--instance-name", prompt="Instance Name", help="Your tenant ID.")
89
91
  @click.option("--dbt_core_integration_id", prompt="DBT Core Integration ID", help="DBT Core Integration ID")
92
+ @click.option(
93
+ "--dbt_core_integration_environment", default="PROD", prompt="DBT Core Integration Environment", help="DBT Core Integration Environment"
94
+ )
90
95
  @click.option("--manifest-path", required=True, prompt="Manifest Path", help="Path to the manifest file.")
96
+ @click.option("--catalog-path", required=False, prompt=False, help="Path to the catalog file.")
91
97
  @click.option("--backend-url", required=False, help="Altimate's Backend URL", default="https://api.myaltimate.com")
92
- def onboard(token, instance_name, dbt_core_integration_id, manifest_path, backend_url="https://api.myaltimate.com", env=None):
98
+ def onboard(
99
+ token,
100
+ instance_name,
101
+ dbt_core_integration_id,
102
+ dbt_core_integration_environment,
103
+ manifest_path,
104
+ catalog_path,
105
+ backend_url="https://api.myaltimate.com",
106
+ ):
93
107
  """Onboard a manifest file to DBT."""
94
108
  check_token_and_instance(token, instance_name)
95
109
 
@@ -104,9 +118,32 @@ def onboard(token, instance_name, dbt_core_integration_id, manifest_path, backen
104
118
  click.echo(f"Error: {e}")
105
119
  return
106
120
 
107
- response = onboard_manifest(token, instance_name, dbt_core_integration_id, manifest_path, backend_url)
108
-
121
+ response = onboard_file(
122
+ token, instance_name, dbt_core_integration_id, dbt_core_integration_environment, "manifest", manifest_path, backend_url
123
+ )
109
124
  if response["ok"]:
110
125
  click.echo("Manifest onboarded successfully!")
111
126
  else:
112
127
  click.echo(f"{response['message']}")
128
+
129
+ if not catalog_path:
130
+ return
131
+
132
+ response = onboard_file(
133
+ token, instance_name, dbt_core_integration_id, dbt_core_integration_environment, "catalog", catalog_path, backend_url
134
+ )
135
+ if response["ok"]:
136
+ click.echo("Catalog onboarded successfully!")
137
+ else:
138
+ click.echo(f"{response['message']}")
139
+
140
+ response = start_dbt_ingestion(token, instance_name, dbt_core_integration_id, dbt_core_integration_environment, backend_url)
141
+ if response["ok"]:
142
+ url = map_url_to_instance(backend_url, instance_name)
143
+ if not url:
144
+ click.echo("Manifest and catalog ingestion has started.")
145
+ else:
146
+ url = f"{url}/settings/integrations/{dbt_core_integration_id}/{dbt_core_integration_environment}"
147
+ click.echo(f"Manifest and catalog ingestion has started. You can check the status at {url}")
148
+ else:
149
+ click.echo(f"{response['message']}")
datapilot/utils/utils.py CHANGED
@@ -311,7 +311,14 @@ def generate_partial_manifest_catalog(changed_files, base_path: str = "./"):
311
311
  raise Exception("Unable to generate partial manifest and catalog") from e
312
312
 
313
313
 
314
- if __name__ == "__main__":
315
- print("Running main")
316
- print(generate_partial_manifest_catalog([], "/Users/gaurp/Desktop/manifest.json", ""))
317
- print("Done running main")
314
+ def map_url_to_instance(url, instance):
315
+ # Base URLs and their corresponding patterns
316
+ url_mapping = {
317
+ "https://api.tryaltimate.com": f"https://{instance}.demo.tryaltimate.com",
318
+ "https://api.myaltimate.com": f"https://{instance}.app.myaltimate.com",
319
+ "https://api.getaltimate.com": f"https://{instance}.app.getaltimate.com",
320
+ "http://localhost:8000": f"http://{instance}.localhost:3000",
321
+ }
322
+
323
+ # Check if the URL is in the dictionary and return the corresponding instance URL
324
+ return url_mapping.get(url)