This is an automated email from the ASF dual-hosted git repository.
eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 196a235358 fix: set dry_run to be optional. (#35167)
196a235358 is described below
commit 196a235358de21c62aedca1347b2527600e8ae87
Author: austinau <[email protected]>
AuthorDate: Sat Nov 25 01:15:49 2023 -0700
fix: set dry_run to be optional. (#35167)
* fix: set dry_run to be optional.
* Update tests/api_connexion/schemas/test_task_instance_schema.py
* Removed extra whitespace.
---------
Co-authored-by: austin <[email protected]>
Co-authored-by: Elad Kalif <[email protected]>
---
airflow/api_connexion/schemas/task_instance_schema.py | 2 +-
tests/api_connexion/schemas/test_task_instance_schema.py | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/airflow/api_connexion/schemas/task_instance_schema.py
b/airflow/api_connexion/schemas/task_instance_schema.py
index 02dc1fb3f6..c9084151d8 100644
--- a/airflow/api_connexion/schemas/task_instance_schema.py
+++ b/airflow/api_connexion/schemas/task_instance_schema.py
@@ -155,7 +155,7 @@ class ClearTaskInstanceFormSchema(Schema):
class SetTaskInstanceStateFormSchema(Schema):
"""Schema for handling the request of setting state of task instance of a
DAG."""
- dry_run = fields.Boolean(dump_default=True)
+ dry_run = fields.Boolean(load_default=True)
task_id = fields.Str(required=True)
execution_date = fields.DateTime(validate=validate_istimezone)
dag_run_id = fields.Str()
diff --git a/tests/api_connexion/schemas/test_task_instance_schema.py
b/tests/api_connexion/schemas/test_task_instance_schema.py
index 76047498d2..55acbb8b95 100644
--- a/tests/api_connexion/schemas/test_task_instance_schema.py
+++ b/tests/api_connexion/schemas/test_task_instance_schema.py
@@ -237,6 +237,22 @@ class TestSetTaskInstanceStateFormSchema:
}
assert expected_result == result
+ def test_dry_run_is_optional(self):
+ data = self.current_input.copy()
+ data.pop("dry_run")
+ result = set_task_instance_state_form.load(self.current_input)
+ expected_result = {
+ "dry_run": True,
+ "execution_date": dt.datetime(2020, 1, 1, 0, 0,
tzinfo=dt.timezone(dt.timedelta(0), "+0000")),
+ "include_downstream": True,
+ "include_future": True,
+ "include_past": True,
+ "include_upstream": True,
+ "new_state": "failed",
+ "task_id": "print_the_context",
+ }
+ assert expected_result == result
+
@pytest.mark.parametrize(
"override_data",
[