From 5da69029ff9181fb4eb79645e9b0488498664270 Mon Sep 17 00:00:00 2001 From: Sean <66645429+seanpwlms@users.noreply.github.com> Date: Fri, 9 Aug 2024 11:47:42 -0700 Subject: [PATCH] prefect-dbt - Clarify missing profile error (#14868) Co-authored-by: Alexander Streed --- .../prefect-dbt/prefect_dbt/cli/commands.py | 15 +++++++++------ .../prefect-dbt/tests/cli/test_commands.py | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/integrations/prefect-dbt/prefect_dbt/cli/commands.py b/src/integrations/prefect-dbt/prefect_dbt/cli/commands.py index 54e5743937b3..84538620fafa 100644 --- a/src/integrations/prefect-dbt/prefect_dbt/cli/commands.py +++ b/src/integrations/prefect-dbt/prefect_dbt/cli/commands.py @@ -143,7 +143,10 @@ def trigger_dbt_cli_command_flow(): # write the profile if overwrite or no profiles exist if overwrite_profiles or not Path(profiles_path).expanduser().exists(): if dbt_cli_profile is None: - raise ValueError("Provide `dbt_cli_profile` keyword for writing profiles") + raise ValueError( + "Profile not found. Provide `dbt_cli_profile` or" + f" ensure profiles.yml exists at {profiles_path}." + ) profile = dbt_cli_profile.get_profile() Path(profiles_dir).expanduser().mkdir(exist_ok=True) with open(profiles_path, "w+") as f: @@ -204,11 +207,11 @@ def _stream_output(event): ) else: logger.debug( - f"Artifacts were not created for dbt {command} this task \ - due to create_artifact=False or the dbt command did not \ - return any RunExecutionResults. \ - See https://docs.getdbt.com/reference/programmatic-invocations \ - for more details on dbtRunnerResult." + f"Artifacts were not created for dbt {command} this task " + "due to create_artifact=False or the dbt command did not " + "return any RunExecutionResults. " + "See https://docs.getdbt.com/reference/programmatic-invocations " + "for more details on dbtRunnerResult." ) if isinstance(result.result, RunExecutionResult) and not result.success: return Failed( diff --git a/src/integrations/prefect-dbt/tests/cli/test_commands.py b/src/integrations/prefect-dbt/tests/cli/test_commands.py index ac5729c48e8a..00c5f08036fb 100644 --- a/src/integrations/prefect-dbt/tests/cli/test_commands.py +++ b/src/integrations/prefect-dbt/tests/cli/test_commands.py @@ -216,7 +216,7 @@ def test_flow(): ) with pytest.raises( - ValueError, match="Provide `dbt_cli_profile` keyword for writing profiles" + ValueError, match="Profile not found. Provide `dbt_cli_profile` or" ): test_flow()