ashb commented on code in PR #46584:
URL: https://github.com/apache/airflow/pull/46584#discussion_r1966582615
##########
airflow/exceptions.py:
##########
@@ -395,6 +395,19 @@ class ConnectionNotUnique(AirflowException):
"""Raise when multiple values are found for the same connection ID."""
+class DownstreamTasksSkipped(BaseException):
Review Comment:
This score inherit from Exception, not BaseException (mainly nothing should
use Base unless you only you need it)
##########
tests/api_fastapi/execution_api/routes/test_task_instances.py:
##########
@@ -718,6 +719,37 @@ def test_ti_runtime_checks_failure(self, client, session,
create_task_instance):
session.expire_all()
+class TestTISkipDownstream:
+ def setup_method(self):
+ clear_db_runs()
+
+ def teardown_method(self):
+ clear_db_runs()
+
+
+ def test_ti_skip_downstream(
+ self, client, session, create_task_instance, dag_maker
+ ):
+ # from airflow import settings
+ # session = settings.Session()
+ with dag_maker("skip_downstream_dag", session=session):
+ t0 = EmptyOperator(task_id="t0")
+ t1 = EmptyOperator(task_id="t1")
+ t0 >> t1
+ dr = dag_maker.create_dagrun(run_id="run")
+ ti0 = dr.get_task_instance("t0", session=session)
+ ti1 = dr.get_task_instance("t1", session=session)
+ ti0.run()
+ response = client.patch(
+ f"/execution/task-instances/{ti0.id}/skip-downstream",
+ json={"tasks": ["t1"]},
+ )
+ # TODO: How to sync the session in Task SDK?
+ assert response.status_code == 204
+ assert ti0.state == State.SUCCESS
+ assert ti1.state == State.SKIPPED # <- This is failing
Review Comment:
You probably need to apply the need_serialized marker to this test - that
will make dag_maker put it in the serialized dag table.
(We're getting to the point where they dorks be the default behaviour of
that fixture, as everything in the scheduler and api server needs it)
##########
task_sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -693,6 +694,16 @@ def run(
return state, msg, error
+def _handle_current_task_success(context, ti) -> tuple[SucceedTask,
TerminalTIState]:
Review Comment:
Is this called anywhere?
##########
newsfragments/44912.bugfix.rst:
##########
Review Comment:
Not needed, at release it goes from working to working, so this news
fragment doesn't make sense to users :)
##########
airflow/ti_deps/deps/not_previously_skipped_dep.py:
##########
@@ -49,11 +48,12 @@ def _get_dep_statuses(self, ti, session, dep_context):
finished_task_ids = {t.task_id for t in finished_tis}
for parent in upstream:
- if isinstance(parent, SkipMixin):
+ if parent.inherits_from_skippable_mixin:
if parent.task_id not in finished_task_ids:
# This can happen if the parent task has not yet run.
continue
+ # TODO: fix double encoding
https://github.com/apache/airflow/issues/45231
Review Comment:
This is merged now
--
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]