Lee-W commented on code in PR #38868:
URL: https://github.com/apache/airflow/pull/38868#discussion_r1587350584
##########
airflow/providers/dbt/cloud/hooks/dbt.py:
##########
@@ -413,6 +414,8 @@ def trigger_job_run(
instead of those configured in dbt Cloud.
:param schema_override: Optional. Override the destination schema in
the configured target for this
job.
+ :param retry_from_failure: Optional. If set to True, the job will be
triggered using the "rerun"
Review Comment:
I thing we should mention this is mutually exclusive with `steps_override,
schema_override, or additional_run_config`
##########
tests/providers/dbt/cloud/hooks/test_dbt.py:
##########
@@ -394,6 +394,70 @@ def test_trigger_job_run_with_additional_run_configs(
)
hook._paginate.assert_not_called()
+ @pytest.mark.parametrize(
+ argnames="conn_id, account_id",
+ argvalues=[(ACCOUNT_ID_CONN, None), (NO_ACCOUNT_ID_CONN, ACCOUNT_ID)],
Review Comment:
nitpick: Why are `argnames`, `argvalues` needed here but not the first
decorator? Let's keep them consistent
##########
tests/providers/dbt/cloud/hooks/test_dbt.py:
##########
@@ -394,6 +394,70 @@ def test_trigger_job_run_with_additional_run_configs(
)
hook._paginate.assert_not_called()
+ @pytest.mark.parametrize(
+ argnames="conn_id, account_id",
+ argvalues=[(ACCOUNT_ID_CONN, None), (NO_ACCOUNT_ID_CONN, ACCOUNT_ID)],
+ ids=["default_account", "explicit_account"],
+ )
+ @pytest.mark.parametrize(
+ "steps_override, schema_override, additional_run_config, expect_error",
+ [
+ (None, None, None, False),
+ (["dbt test", "dbt run"], None, None, True),
+ (None, ["other_schema"], None, True),
+ (None, None, {"threads_override": 8, "generate_docs_override":
False}, True),
+ ],
+ )
+ @patch.object(DbtCloudHook, "run")
+ @patch.object(DbtCloudHook, "_paginate")
+ def test_trigger_job_run_with_retry_from_failure(
+ self,
+ mock_http_run,
+ mock_paginate,
+ conn_id,
+ account_id,
+ steps_override,
+ schema_override,
+ additional_run_config,
+ expect_error,
+ ):
+ hook = DbtCloudHook(conn_id)
+ cause = ""
+ retry_from_failure = True
+ error_match = (
+ "steps_override, schema_override, or additional_run_config"
+ " cannot be used when retry_from_failure is True"
+ )
+
+ if expect_error:
+ with pytest.raises(ValueError, match=error_match):
+ hook.trigger_job_run(
+ job_id=JOB_ID,
+ cause=cause,
+ account_id=account_id,
+ steps_override=steps_override,
+ schema_override=schema_override,
+ additional_run_config=additional_run_config,
+ retry_from_failure=retry_from_failure,
+ )
+ else:
Review Comment:
Let's split the success and fail cases into 2 test functions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]