From a83c34fcb668df5ec84fabbf06325e892b6d2280 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 10 Jan 2023 10:06:08 -0600 Subject: [PATCH 1/5] rename exceptions --- dbt/adapters/redshift/connections.py | 8 ++++---- dbt/adapters/redshift/impl.py | 6 +++--- dev-requirements.txt | 6 +++--- tests/unit/test_context.py | 2 +- tests/unit/test_redshift_adapter.py | 1 - 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/dbt/adapters/redshift/connections.py b/dbt/adapters/redshift/connections.py index be4d626d3..a13353950 100644 --- a/dbt/adapters/redshift/connections.py +++ b/dbt/adapters/redshift/connections.py @@ -114,7 +114,7 @@ def fetch_cluster_credentials( ) except boto_client.exceptions.ClientError as e: - raise dbt.exceptions.FailedToConnectException( + raise dbt.exceptions.FailedToConnectError( "Unable to get temporary Redshift cluster credentials: {}".format(e) ) @@ -127,7 +127,7 @@ def get_tmp_iam_cluster_credentials(cls, credentials): iam_duration_s = credentials.iam_duration_seconds if not cluster_id: - raise dbt.exceptions.FailedToConnectException( + raise dbt.exceptions.FailedToConnectError( "'cluster_id' must be provided in profile if IAM " "authentication method selected" ) @@ -156,7 +156,7 @@ def get_credentials(cls, credentials): # this requirement is really annoying to encode into json schema, # so validate it here if credentials.password is None: - raise dbt.exceptions.FailedToConnectException( + raise dbt.exceptions.FailedToConnectError( "'password' field is required for 'database' credentials" ) return credentials @@ -166,6 +166,6 @@ def get_credentials(cls, credentials): return cls.get_tmp_iam_cluster_credentials(credentials) else: - raise dbt.exceptions.FailedToConnectException( + raise dbt.exceptions.FailedToConnectError( "Invalid 'method' in profile: '{}'".format(method) ) diff --git a/dbt/adapters/redshift/impl.py b/dbt/adapters/redshift/impl.py index 206185f57..4ece2ff51 100644 --- a/dbt/adapters/redshift/impl.py +++ b/dbt/adapters/redshift/impl.py @@ -72,7 +72,7 @@ def verify_database(self, database): ra3_node = self.config.credentials.ra3_node if database.lower() != expected.lower() and not ra3_node: - raise dbt.exceptions.NotImplementedException( + raise dbt.exceptions.NotImplementedError( "Cross-db references allowed only in RA3.* node. ({} vs {})".format( database, expected ) @@ -85,8 +85,8 @@ def _get_catalog_schemas(self, manifest): schemas = super(SQLAdapter, self)._get_catalog_schemas(manifest) try: return schemas.flatten(allow_multiple_databases=self.config.credentials.ra3_node) - except dbt.exceptions.RuntimeException as exc: - dbt.exceptions.raise_compiler_error( + except dbt.exceptions.DbtRuntimeError as exc: + raise dbt.exceptions.CompilationError( "Cross-db references allowed only in {} RA3.* node. Got {}".format( self.type(), exc.msg ) diff --git a/dev-requirements.txt b/dev-requirements.txt index 6eac3d2b4..a81b63448 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,8 @@ # install latest changes in dbt-core + dbt-postgres # TODO: how to switch from HEAD to x.y.latest branches after minor releases? -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-postgres&subdirectory=plugins/postgres +git+https://github.com/dbt-labs/dbt-core.git@er/ct-1687-rename-exceptions#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@er/ct-1687-rename-exceptions#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git@er/ct-1687-rename-exceptions#egg=dbt-postgres&subdirectory=plugins/postgres black~=22.8.0 click~=8.1.3 diff --git a/tests/unit/test_context.py b/tests/unit/test_context.py index 5b975d029..5170fcfbf 100644 --- a/tests/unit/test_context.py +++ b/tests/unit/test_context.py @@ -212,7 +212,7 @@ def test_resolve_specific(config, manifest_extended, redshift_adapter, get_inclu ctx['adapter'].config.dispatch # macro_a exists, but default__macro_a and redshift__macro_a do not - with pytest.raises(dbt.exceptions.CompilationException): + with pytest.raises(dbt.exceptions.CompilationError): ctx['adapter'].dispatch('macro_a').macro # root namespace is always preferred, unless search order is explicitly defined in 'dispatch' config diff --git a/tests/unit/test_redshift_adapter.py b/tests/unit/test_redshift_adapter.py index 33c3dc1aa..34bbe07e4 100644 --- a/tests/unit/test_redshift_adapter.py +++ b/tests/unit/test_redshift_adapter.py @@ -10,7 +10,6 @@ Plugin as RedshiftPlugin, ) from dbt.clients import agate_helper -from dbt.exceptions import FailedToConnectException from .utils import config_from_parts_or_dicts, mock_connection, TestAdapterConversions, inject_adapter From c793821f05121126fd7baf9a4abd1e686d3ad049 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 10 Jan 2023 10:06:58 -0600 Subject: [PATCH 2/5] add changelog --- .changes/unreleased/Under the Hood-20230110-100647.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20230110-100647.yaml diff --git a/.changes/unreleased/Under the Hood-20230110-100647.yaml b/.changes/unreleased/Under the Hood-20230110-100647.yaml new file mode 100644 index 000000000..a6abb0c91 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230110-100647.yaml @@ -0,0 +1,7 @@ +kind: Under the Hood +body: Rename exceptions to match dbt-core +time: 2023-01-10T10:06:47.570088-06:00 +custom: + Author: emmyoop + Issue: "250" + PR: "0" From 1516407f2e08e3d1eb11a4e4a964f233c653d9f0 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 10 Jan 2023 12:57:41 -0600 Subject: [PATCH 3/5] fix unit test --- tests/unit/test_redshift_adapter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_redshift_adapter.py b/tests/unit/test_redshift_adapter.py index 34bbe07e4..92fd9cbd8 100644 --- a/tests/unit/test_redshift_adapter.py +++ b/tests/unit/test_redshift_adapter.py @@ -10,6 +10,7 @@ Plugin as RedshiftPlugin, ) from dbt.clients import agate_helper +from dbt.exceptions import FailedToConnectError from .utils import config_from_parts_or_dicts, mock_connection, TestAdapterConversions, inject_adapter @@ -114,7 +115,7 @@ def test_invalid_auth_method(self): # we have to set method this way, otherwise it won't validate self.config.credentials.method = 'badmethod' - with self.assertRaises(FailedToConnectException) as context: + with self.assertRaises(FailedToConnectError) as context: with mock.patch.object( RedshiftAdapter.ConnectionManager, 'fetch_cluster_credentials', @@ -126,7 +127,7 @@ def test_invalid_auth_method(self): def test_invalid_iam_no_cluster_id(self): self.config.credentials = self.config.credentials.replace(method='iam') - with self.assertRaises(FailedToConnectException) as context: + with self.assertRaises(FailedToConnectError) as context: with mock.patch.object( RedshiftAdapter.ConnectionManager, 'fetch_cluster_credentials', From 627588878726b5baf58b8ae0a9d5b2eb76a1b4dd Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 10 Jan 2023 16:46:58 -0600 Subject: [PATCH 4/5] point back to main --- dev-requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index a81b63448..6eac3d2b4 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,8 +1,8 @@ # install latest changes in dbt-core + dbt-postgres # TODO: how to switch from HEAD to x.y.latest branches after minor releases? -git+https://github.com/dbt-labs/dbt-core.git@er/ct-1687-rename-exceptions#egg=dbt-core&subdirectory=core -git+https://github.com/dbt-labs/dbt-core.git@er/ct-1687-rename-exceptions#egg=dbt-tests-adapter&subdirectory=tests/adapter -git+https://github.com/dbt-labs/dbt-core.git@er/ct-1687-rename-exceptions#egg=dbt-postgres&subdirectory=plugins/postgres +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-postgres&subdirectory=plugins/postgres black~=22.8.0 click~=8.1.3 From 5e2251939de3557fb038f5362ee90c447fe49fc6 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 10 Jan 2023 18:10:09 -0600 Subject: [PATCH 5/5] Update Under the Hood-20230110-100647.yaml --- .changes/unreleased/Under the Hood-20230110-100647.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/unreleased/Under the Hood-20230110-100647.yaml b/.changes/unreleased/Under the Hood-20230110-100647.yaml index a6abb0c91..a0dad2abf 100644 --- a/.changes/unreleased/Under the Hood-20230110-100647.yaml +++ b/.changes/unreleased/Under the Hood-20230110-100647.yaml @@ -4,4 +4,4 @@ time: 2023-01-10T10:06:47.570088-06:00 custom: Author: emmyoop Issue: "250" - PR: "0" + PR: "258"