-
Notifications
You must be signed in to change notification settings - Fork 2
feat: manifest onboarding #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import logging | ||
|
|
||
| import requests | ||
|
|
||
|
|
||
| class APIClient: | ||
| def __init__(self, api_token="", base_url="", tenant=""): | ||
| self.api_token = api_token | ||
| self.base_url = base_url | ||
| self.tenant = tenant | ||
| self.logger = logging.getLogger(self.__class__.__name__) | ||
|
|
||
| def _get_headers(self): | ||
| headers = { | ||
| "Content-Type": "application/json", | ||
| } | ||
|
|
||
| if self.api_token: | ||
| headers["Authorization"] = f"Bearer {self.api_token}" | ||
|
|
||
| if self.tenant: | ||
| headers["x-tenant"] = self.tenant | ||
|
|
||
| return headers | ||
|
|
||
| def get(self, endpoint, params=None): | ||
| url = f"{self.base_url}{endpoint}" | ||
| headers = self._get_headers() | ||
|
|
||
| self.logger.debug(f"Sending GET request for tenant {self.tenant} at url: {url}") | ||
| print(f"Sending GET request for tenant {self.tenant} at url: {url}") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use prints
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prints are the only thing that are appearing in my terminal. logger.debug isn't showing up at all |
||
| response = requests.get(url, headers=headers, params=params) | ||
| self.logger.debug(f"Received GET response with status: {response.status_code }") | ||
| return response.json() if response.status_code == 200 else None | ||
|
|
||
| def post(self, endpoint, data=None): | ||
| url = f"{self.base_url}{endpoint}" | ||
| headers = self._get_headers() | ||
|
|
||
| self.logger.debug(f"Sending POST request for tenant {self.tenant} at url: {url}") | ||
| response = requests.post(url, headers=headers, json=data) | ||
| self.logger.debug(f"Received POST response with status: {response.status_code }") | ||
|
|
||
| return response | ||
|
|
||
| def put(self, endpoint, data): | ||
| url = f"{self.base_url}{endpoint}" | ||
| headers = self._get_headers() | ||
|
|
||
| self.logger.debug(f"Sending PUT request for tenant {self.tenant} at url: {url}") | ||
| response = requests.put(url, data=data) | ||
| self.logger.debug(f"Received PUT response with status: {response.status_code}") | ||
| return response | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,15 @@ | ||
| import logging | ||
| import os | ||
|
|
||
| import click | ||
|
|
||
| from datapilot.config.config import load_config | ||
| from datapilot.core.platforms.dbt.constants import MODEL, PROJECT | ||
| from datapilot.core.platforms.dbt.executor import DBTInsightGenerator | ||
| from datapilot.core.platforms.dbt.formatting import ( | ||
| generate_model_insights_table, generate_project_insights_table) | ||
| from datapilot.core.platforms.dbt.formatting import generate_model_insights_table, generate_project_insights_table | ||
| from datapilot.core.platforms.dbt.utils import load_manifest | ||
| from datapilot.utils.formatting.utils import tabulate_data | ||
| from datapilot.utils.utils import onboard_manifest | ||
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
|
|
||
|
|
@@ -64,3 +66,30 @@ def project_health(manifest_path, catalog_path, config_path=None): | |
| click.echo("Project Insights") | ||
| click.echo("--" * 50) | ||
| click.echo(tabulate_data(project_report, headers="keys")) | ||
|
|
||
|
|
||
| @dbt.command("onboard") | ||
| @click.option("--token", prompt="API Token", help="Your API token for authentication.") | ||
| @click.option("--tenant", prompt="Tenant", help="Your tenant ID.") | ||
| @click.option("--dbt_core_integration_id", prompt="DBT Core Integration ID", help="DBT Core Integration ID") | ||
| @click.option("--manifest-path", required=True, prompt="Manifest Path", help="Path to the manifest file.") | ||
| def onboard(token, tenant, dbt_core_integration_id, manifest_path, env=None): | ||
| """Onboard a manifest file to DBT.""" | ||
| if not token and env: | ||
| token = os.environ.get("ALTIMATE_API_KEY") | ||
|
|
||
| if not tenant and env: | ||
| tenant = os.environ.get("ALTIMATE_INSTANCE_NAME") | ||
|
|
||
| if not token or not tenant: | ||
| click.echo("Error: API Token is required.") | ||
| return | ||
|
|
||
| # if not validate_credentials(token, tenant): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason? |
||
| # print("Error: Invalid credentials.") | ||
| # return | ||
|
|
||
| # This will throw error if manifest file is incorrect | ||
| # load_manifest(manifest_path) | ||
|
|
||
| onboard_manifest(token, tenant, dbt_core_integration_id, manifest_path) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| from .documentation_on_stale_columns import DBTDocumentationStaleColumns | ||
| from .exposures_dependent_on_private_models import \ | ||
| DBTExposureDependentOnPrivateModels | ||
| from .exposures_dependent_on_private_models import DBTExposureDependentOnPrivateModels | ||
| from .public_models_without_contracts import DBTPublicModelWithoutContracts | ||
| from .undocumented_columns import DBTMissingDocumentation | ||
| from .undocumented_public_models import DBTUndocumentedPublicModels |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,12 @@ | ||
| from .direct_join_to_source import DBTDirectJoinSource | ||
| from .downstream_models_dependent_on_source import \ | ||
| DBTDownstreamModelsDependentOnSource | ||
| from .downstream_models_dependent_on_source import DBTDownstreamModelsDependentOnSource | ||
| from .duplicate_sources import DBTDuplicateSources | ||
| from .hard_coded_references import DBTHardCodedReferences | ||
| from .joining_of_upstream_concepts import DBTRejoiningOfUpstreamConcepts | ||
| from .model_fanout import DBTModelFanout | ||
| from .multiple_sources_joined import DBTModelsMultipleSourcesJoined | ||
| from .root_model import DBTRootModel | ||
| from .source_fanout import DBTSourceFanout | ||
| from .staging_model_dependent_on_downstream_models import \ | ||
| DBTStagingModelsDependentOnDownstreamModels | ||
| from .staging_model_dependent_on_staging_models import \ | ||
| DBTStagingModelsDependentOnStagingModels | ||
| from .staging_model_dependent_on_downstream_models import DBTStagingModelsDependentOnDownstreamModels | ||
| from .staging_model_dependent_on_staging_models import DBTStagingModelsDependentOnStagingModels | ||
| from .unused_sources import DBTUnusedSources |
Uh oh!
There was an error while loading. Please reload this page.