amoghrajesh commented on code in PR #76295:
URL: https://github.com/apache/airflow/pull/76295#discussion_r4509242225
##########
providers/databricks/tests/unit/databricks/operators/test_databricks.py:
##########
@@ -5267,3 +5269,218 @@ def
test_monitor_waits_out_waiting_for_retry_state(self, mock_databricks_hook, m
operator.monitor_databricks_job()
assert mock_databricks_hook.return_value.get_run.call_count == 3
+
+
[email protected](
+ not AIRFLOW_V_3_3_PLUS, reason="task_state_store (durable execution)
requires Airflow 3.3+"
+)
+class TestDatabricksTaskBaseOperatorDurable:
+ @pytest.fixture(params=["notebook", "task"])
+ def make_operator(self, request):
+ def _make(**kwargs):
+ if request.param == "notebook":
+ return DatabricksNotebookOperator(
+ task_id=TASK_ID,
+ notebook_path="/test",
+ source="WORKSPACE",
+ new_cluster=NEW_CLUSTER,
+ **kwargs,
+ )
+ return DatabricksTaskOperator(
+ task_id=TASK_ID,
+ task_config={"notebook_task": NOTEBOOK_TASK},
+ new_cluster=NEW_CLUSTER,
+ **kwargs,
+ )
+
+ return _make
+
+ @staticmethod
+ def _task_store(stored_run_id=None):
+ task_store = MagicMock(spec_set=["get", "set"])
+ task_store.get.return_value = stored_run_id
+ return task_store
+
+
@mock.patch("airflow.providers.databricks.operators.databricks.DatabricksHook")
+ def test_persists_run_id_on_fresh_submit(self, db_mock_class,
make_operator):
+ op = make_operator()
+ op.monitor_databricks_job = MagicMock()
Review Comment:
Added a test that runs execute() with deferrable=True and checks the run id
is stored before defer fires. Confirmed it fails if you add an `if
self.deferrable:` bypass.
--
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]