-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Drop Connection.schema use in DbtCloudHook #29166
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ | |
|
|
||
| import json | ||
| import time | ||
| import warnings | ||
| from enum import Enum | ||
| from functools import wraps | ||
| from inspect import signature | ||
|
|
@@ -181,33 +180,33 @@ def __init__(self, dbt_cloud_conn_id: str = default_conn_name, *args, **kwargs) | |
| super().__init__(auth_type=TokenAuth) | ||
| self.dbt_cloud_conn_id = dbt_cloud_conn_id | ||
|
|
||
| @staticmethod | ||
| def _get_tenant_domain(conn: Connection) -> str: | ||
| return conn.host or "cloud.getdbt.com" | ||
|
|
||
| @staticmethod | ||
| def get_request_url_params( | ||
| tenant: str, endpoint: str, include_related: list[str] | None = None | ||
| ) -> tuple[str, dict[str, Any]]: | ||
| """ | ||
| Form URL from base url and endpoint url | ||
|
|
||
| :param tenant: The tenant name which is need to be replaced in base url. | ||
| :param tenant: The tenant domain name which is need to be replaced in base url. | ||
| :param endpoint: Endpoint url to be requested. | ||
| :param include_related: Optional. List of related fields to pull with the run. | ||
| Valid values are "trigger", "job", "repository", and "environment". | ||
| """ | ||
| data: dict[str, Any] = {} | ||
| base_url = f"https://{tenant}.getdbt.com/api/v2/accounts/" | ||
| if include_related: | ||
| data = {"include_related": include_related} | ||
| if base_url and not base_url.endswith("/") and endpoint and not endpoint.startswith("/"): | ||
| url = base_url + "/" + endpoint | ||
| else: | ||
| url = (base_url or "") + (endpoint or "") | ||
|
||
| url = f"https://{tenant}/api/v2/accounts/{endpoint or ''}" | ||
| return url, data | ||
|
|
||
| async def get_headers_tenants_from_connection(self) -> tuple[dict[str, Any], str]: | ||
| """Get Headers, tenants from the connection details""" | ||
| headers: dict[str, Any] = {} | ||
| connection: Connection = await sync_to_async(self.get_connection)(self.dbt_cloud_conn_id) | ||
| tenant: str = connection.schema if connection.schema else "cloud" | ||
| tenant = self._get_tenant_domain(connection) | ||
| package_name, provider_version = _get_provider_info() | ||
| headers["User-Agent"] = f"{package_name}-v{provider_version}" | ||
| headers["Content-Type"] = "application/json" | ||
|
|
@@ -267,19 +266,7 @@ def connection(self) -> Connection: | |
| return _connection | ||
|
|
||
| def get_conn(self, *args, **kwargs) -> Session: | ||
| if self.connection.schema: | ||
| warnings.warn( | ||
| "The `schema` parameter is deprecated and use within a dbt Cloud connection will be removed " | ||
| "in a future version. Please use `host` instead and specify the entire tenant domain name.", | ||
| category=DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| # Prior to deprecation, the connection.schema value could _only_ modify the third-level | ||
| # domain value while '.getdbt.com' was always used as the remainder of the domain name. | ||
| tenant = f"{self.connection.schema}.getdbt.com" | ||
| else: | ||
| tenant = self.connection.host or "cloud.getdbt.com" | ||
|
|
||
| tenant = self._get_tenant_domain(self.connection) | ||
| self.base_url = f"https://{tenant}/api/v2/accounts/" | ||
|
|
||
| session = Session() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old logic that is no longer valid.