Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 8d83250

Browse files
committed
DataDiff prefix
1 parent 42d330a commit 8d83250

File tree

3 files changed

+68
-68
lines changed

3 files changed

+68
-68
lines changed

data_diff/dbt_parser.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
from dbt.config.renderer import ProfileRenderer
1313

1414
from data_diff.errors import (
15-
DbtBigQueryOauthOnlyError,
16-
DbtConnectionNotImplementedError,
17-
DbtCoreNoRunnerError,
18-
DbtNoSuccessfulModelsInRunError,
19-
DbtProfileNotFoundError,
20-
DbtProjectVarsNotFoundError,
21-
DbtRedshiftPasswordOnlyError,
22-
DbtRunResultsVersionError,
23-
DbtSelectNoMatchingModelsError,
24-
DbtSelectUnexpectedError,
25-
DbtSelectVersionTooLowError,
26-
DbtSnowflakeSetConnectionError,
15+
DataDiffDbtBigQueryOauthOnlyError,
16+
DataDiffDbtConnectionNotImplementedError,
17+
DataDiffDbtCoreNoRunnerError,
18+
DataDiffDbtNoSuccessfulModelsInRunError,
19+
DataDiffDbtProfileNotFoundError,
20+
DataDiffDbtProjectVarsNotFoundError,
21+
DataDiffDbtRedshiftPasswordOnlyError,
22+
DataDiffDbtRunResultsVersionError,
23+
DataDiffDbtSelectNoMatchingModelsError,
24+
DataDiffDbtSelectUnexpectedError,
25+
DataDiffDbtSelectVersionTooLowError,
26+
DataDiffDbtSnowflakeSetConnectionError,
2727
)
2828

2929
from .utils import getLogger, get_from_dict_with_raise
@@ -108,7 +108,7 @@ def __init__(self, profiles_dir_override: str, project_dir_override: str) -> Non
108108

109109
def get_datadiff_variables(self) -> dict:
110110
doc_url = "https://docs.datafold.com/development_testing/open_source#configure-your-dbt-project"
111-
exception = DbtProjectVarsNotFoundError(
111+
exception = DataDiffDbtProjectVarsNotFoundError(
112112
f"vars: data_diff: section not found in dbt_project.yml.\n\nTo solve this, please configure your dbt project: \n{doc_url}\n"
113113
)
114114
vars_dict = get_from_dict_with_raise(self.project_dict, "vars", exception)
@@ -137,11 +137,11 @@ def get_models(self, dbt_selection: Optional[str] = None):
137137
return self.get_dbt_selection_models(dbt_selection)
138138
# edge case if running data-diff from a separate env than dbt (likely local development)
139139
else:
140-
raise DbtCoreNoRunnerError(
140+
raise DataDiffDbtCoreNoRunnerError(
141141
"data-diff is using a dbt-core version < 1.5, update the environment's dbt-core version via pip install 'dbt-core>=1.5' in order to use `--select`"
142142
)
143143
else:
144-
raise DbtSelectVersionTooLowError(
144+
raise DataDiffDbtSelectVersionTooLowError(
145145
f"The `--select` feature requires dbt >= 1.5, but your project's manifest.json is from dbt v{dbt_version}. Please follow these steps to use the `--select` feature: \n 1. Update your dbt-core version via pip install 'dbt-core>=1.5'. Details: https://docs.getdbt.com/docs/core/pip-install#change-dbt-core-versions \n 2. Execute any `dbt` command (`run`, `compile`, `build`) to create a new manifest.json."
146146
)
147147
else:
@@ -178,10 +178,10 @@ def get_dbt_selection_models(self, dbt_selection: str) -> List[str]:
178178
return models
179179

180180
if not results.result:
181-
raise DbtSelectNoMatchingModelsError(f"No dbt models found for `--select {dbt_selection}`")
181+
raise DataDiffDbtSelectNoMatchingModelsError(f"No dbt models found for `--select {dbt_selection}`")
182182

183183
logger.debug(str(results))
184-
raise DbtSelectUnexpectedError("Encountered an unexpected error while finding `--select` models")
184+
raise DataDiffDbtSelectUnexpectedError("Encountered an unexpected error while finding `--select` models")
185185

186186
def get_run_results_models(self):
187187
with open(self.project_dir / RUN_RESULTS_PATH) as run_results:
@@ -195,7 +195,7 @@ def get_run_results_models(self):
195195
self.profiles_dir = legacy_profiles_dir()
196196

197197
if dbt_version < parse_version(LOWER_DBT_V):
198-
raise DbtRunResultsVersionError(
198+
raise DataDiffDbtRunResultsVersionError(
199199
f"Found dbt: v{dbt_version} Expected the dbt project's version to be >= {LOWER_DBT_V}"
200200
)
201201
if dbt_version >= parse_version(UPPER_DBT_V):
@@ -206,7 +206,7 @@ def get_run_results_models(self):
206206
success_models = [x.unique_id for x in run_results_obj.results if x.status.name == "success"]
207207
models = [self.manifest_obj.nodes.get(x) for x in success_models]
208208
if not models:
209-
raise DbtNoSuccessfulModelsInRunError("Expected > 0 successful models runs from the last dbt command.")
209+
raise DataDiffDbtNoSuccessfulModelsInRunError("Expected > 0 successful models runs from the last dbt command.")
210210

211211
print(f"Running with data-diff={__version__}\n")
212212
return models
@@ -235,31 +235,31 @@ def get_connection_creds(self) -> Tuple[Dict[str, str], str]:
235235
profile = get_from_dict_with_raise(
236236
profiles,
237237
dbt_profile_var,
238-
DbtProfileNotFoundError(f"No profile '{dbt_profile_var}' found in '{profiles_path}'."),
238+
DataDiffDbtProfileNotFoundError(f"No profile '{dbt_profile_var}' found in '{profiles_path}'."),
239239
)
240240
# values can contain env_vars
241241
rendered_profile = ProfileRenderer().render_data(profile)
242242
profile_target = get_from_dict_with_raise(
243243
rendered_profile,
244244
"target",
245-
DbtProfileNotFoundError(f"No target found in profile '{dbt_profile_var}' in '{profiles_path}'."),
245+
DataDiffDbtProfileNotFoundError(f"No target found in profile '{dbt_profile_var}' in '{profiles_path}'."),
246246
)
247247
outputs = get_from_dict_with_raise(
248248
rendered_profile,
249249
"outputs",
250-
DbtProfileNotFoundError(f"No outputs found in profile '{dbt_profile_var}' in '{profiles_path}'."),
250+
DataDiffDbtProfileNotFoundError(f"No outputs found in profile '{dbt_profile_var}' in '{profiles_path}'."),
251251
)
252252
credentials = get_from_dict_with_raise(
253253
outputs,
254254
profile_target,
255-
DbtProfileNotFoundError(
255+
DataDiffDbtProfileNotFoundError(
256256
f"No credentials found for target '{profile_target}' in profile '{dbt_profile_var}' in '{profiles_path}'."
257257
),
258258
)
259259
conn_type = get_from_dict_with_raise(
260260
credentials,
261261
"type",
262-
DbtProfileNotFoundError(
262+
DataDiffDbtProfileNotFoundError(
263263
f"No type found for target '{profile_target}' in profile '{dbt_profile_var}' in '{profiles_path}'."
264264
),
265265
)
@@ -287,7 +287,7 @@ def set_connection(self):
287287

288288
if credentials.get("private_key_path") is not None:
289289
if credentials.get("password") is not None:
290-
raise DbtSnowflakeSetConnectionError("Cannot use password and key at the same time")
290+
raise DataDiffDbtSnowflakeSetConnectionError("Cannot use password and key at the same time")
291291
conn_info["key"] = credentials.get("private_key_path")
292292
conn_info["private_key_passphrase"] = credentials.get("private_key_passphrase")
293293
elif credentials.get("authenticator") is not None:
@@ -296,13 +296,13 @@ def set_connection(self):
296296
elif credentials.get("password") is not None:
297297
conn_info["password"] = credentials.get("password")
298298
else:
299-
raise DbtSnowflakeSetConnectionError("Snowflake: unsupported auth method")
299+
raise DataDiffDbtSnowflakeSetConnectionError("Snowflake: unsupported auth method")
300300
elif conn_type == "bigquery":
301301
method = credentials.get("method")
302302
# there are many connection types https://docs.getdbt.com/reference/warehouse-setups/bigquery-setup#oauth-via-gcloud
303303
# this assumes that the user is auth'd via `gcloud auth application-default login`
304304
if method is None or method != "oauth":
305-
raise DbtBigQueryOauthOnlyError("Oauth is the current method supported for Big Query.")
305+
raise DataDiffDbtBigQueryOauthOnlyError("Oauth is the current method supported for Big Query.")
306306
conn_info = {
307307
"driver": conn_type,
308308
"project": credentials.get("project"),
@@ -318,7 +318,7 @@ def set_connection(self):
318318
if (credentials.get("pass") is None and credentials.get("password") is None) or credentials.get(
319319
"method"
320320
) == "iam":
321-
raise DbtRedshiftPasswordOnlyError("Only password authentication is currently supported for Redshift.")
321+
raise DataDiffDbtRedshiftPasswordOnlyError("Only password authentication is currently supported for Redshift.")
322322
conn_info = {
323323
"driver": conn_type,
324324
"host": credentials.get("host"),
@@ -349,7 +349,7 @@ def set_connection(self):
349349
}
350350
self.threads = credentials.get("threads")
351351
else:
352-
raise DbtConnectionNotImplementedError(f"Provider {conn_type} is not yet supported for dbt diffs")
352+
raise DataDiffDbtConnectionNotImplementedError(f"Provider {conn_type} is not yet supported for dbt diffs")
353353

354354
self.connection = conn_info
355355

data_diff/errors.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
class DbtProjectVarsNotFoundError(Exception):
1+
class DataDiffDbtProjectVarsNotFoundError(Exception):
22
"Raised when an expected dbt_project.yml section is missing."
33

44

5-
class DbtProfileNotFoundError(Exception):
5+
class DataDiffDbtProfileNotFoundError(Exception):
66
"Raised when an expected profiles.yml section is missing."
77

88

9-
class DbtNoSuccessfulModelsInRunError(Exception):
9+
class DataDiffDbtNoSuccessfulModelsInRunError(Exception):
1010
"Raised when there are no successful model runs in the run_results.json"
1111

1212

13-
class DbtRunResultsVersionError(Exception):
13+
class DataDiffDbtRunResultsVersionError(Exception):
1414
"Raised when the dbt version in run_results.json is lower than the minimum version."
1515

1616

17-
class DbtSelectNoMatchingModelsError(Exception):
17+
class DataDiffDbtSelectNoMatchingModelsError(Exception):
1818
"Raised when the `--select` flag returns no models."
1919

2020

21-
class DbtSelectUnexpectedError(Exception):
21+
class DataDiffDbtSelectUnexpectedError(Exception):
2222
"Catch all for unexpected dbt list --select results."
2323

2424

25-
class DbtSnowflakeSetConnectionError(Exception):
25+
class DataDiffDbtSnowflakeSetConnectionError(Exception):
2626
"Raised when a dbt snowflake profile has unexpected values."
2727

2828

29-
class DbtBigQueryOauthOnlyError(Exception):
29+
class DataDiffDbtBigQueryOauthOnlyError(Exception):
3030
"Raised when trying to use a method other than oauth with BigQuery."
3131

3232

33-
class DbtRedshiftPasswordOnlyError(Exception):
33+
class DataDiffDbtRedshiftPasswordOnlyError(Exception):
3434
"Raised when using a non-password connection method with Redshift."
3535

3636

37-
class DbtConnectionNotImplementedError(Exception):
37+
class DataDiffDbtConnectionNotImplementedError(Exception):
3838
"Raised when trying to use an unsupported dbt connection method."
3939

4040

41-
class DbtCoreNoRunnerError(Exception):
41+
class DataDiffDbtCoreNoRunnerError(Exception):
4242
"Raised when the manifest version >= 1.5, but the dbt-core package is < 1.5. This is an edge case most likely to occur in development."
4343

4444

45-
class DbtSelectVersionTooLowError(Exception):
45+
class DataDiffDbtSelectVersionTooLowError(Exception):
4646
"Raised when attempting to use `--select` with a dbt-core version < 1.5."

0 commit comments

Comments
 (0)