Repository navigation
[BATCH-4364] Port Affirm fork patches onto upstream 2.9.3 (2.9.3+affirm1) - #35
Open
mrafayaleem wants to merge 5 commits into
Open
mrafayaleem wants to merge 5 commits into
mrafayaleem wants to merge 5 commits into
Conversation
Replays the 2.5.1+affirm4 fork delta onto apache/airflow tag 2.9.3 per the 2.5.1 -> 2.9.3 upgrade plan, sections 5.1 and 5.2. Ported: - A1: cancel_dag_run / clear_dag_run experimental API modules, endpoints, and api_client / local_client methods - A2: cancel_task_instances(); import Job from airflow.jobs.job (2.9 has an empty airflow.jobs package) - A3: State.finished is a frozenset; drop the call that raised TypeError - A4: trigger_dag writes an api_trigger_dag audit Log row and defaults execution_date to now - A5: get_dag_runs(**kwargs) + dag_runs dagrun_id / execution_date_gte - A6: DagModel.set_is_paused calls [affirm] toggle_dag_hook - A7: footer version link points at the fork - A11: __version__ = "2.9.3+affirm1" (hatchling; no setup.py in 2.9) Dropped: A8/A9 (upstream since 2.5.3, apache#30084), A10 (RELEASE_NOTES bad-merge artifact), and an unused send_email import in models/dag.py. Fixes found while porting: - A6: models/dag.py imports conf as airflow_conf in 2.9; use that, and pass fallback=None so pause/unpause doesn't raise where the [affirm] section is absent. Prod sets the key, so behaviour there is unchanged. - A1/A3: cancel_dag_run now loads the run and its TIs in its own session. It previously used detached objects, and session.merge(ti) cascaded the stale QUEUED DagRun back over the FAILED state. This was hidden on 2.5.1 because the A3 TypeError fired first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- New tests for cancel_dag_run / clear_dag_run endpoints, including the A3 finished-run regression and RUNNING TI -> SHUTDOWN + job shutdown - dag_runs dagrun_id / execution_date_gte filters and the bad-date 400 - toggle_dag_hook is called on pause when configured - test_trigger_dag: assert the api_trigger_dag audit row; drop the zero-microsecond assertion, since the fork defaults execution_date before replace_microseconds is derived (unchanged from 2.5.1+affirm4) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 28, 2026
pre-commit 4 warns that upstream 2.9.3's .pre-commit-config.yaml uses the deprecated `commit`/`push` stage names, and a later release may reject them outright, which would break compiling the www assets. Install pre-commit>=3.2.0,<4, and reinstall if the venv has 4.x. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the Affirm fork patches from
2.5.1+affirm4onto upstream Apache Airflow 2.9.3, for BATCH-4364. Plan: Airflow 2.5.1 → 2.9.3 Upgrade Plan §5.1–5.2.Affirm changes
cancel_dag_run/clear_dag_runexperimental API modules, endpoints,api_client/local_clientmethodscancel_task_instances()inmodels/taskinstance.pyfrom airflow.jobs.job import Job(the 2.9airflow.jobspackage is empty)cancel_dag_run:State.finished()→State.finishedTypeErrortrigger_dagwrites anapi_trigger_dagauditLogrow and defaultsexecution_dateto nowget_dag_runs(**kwargs)+dag_runsdagrun_id/execution_date_gtefiltersDagModel.set_is_paused→[affirm] toggle_dag_hookti_countguard + test,RELEASE_NOTES.rstedits__version__ = "2.9.3+affirm1"inairflow/__init__.py(hatchling; nosetup.py)Also dropped: an unused
send_emailimport inmodels/dag.py.Fixes found while porting (beyond the plan)
models/dag.pyimports the config asairflow_confin 2.9, so the oldconf.getimport(...)raisedNameErroron every pause/unpause. It also passesfallback=Nonenow, so installs without an[affirm]section skip the hook instead of raising. Prod sets the key, so behaviour there is unchanged.cancel_dag_run: the run and its TIs were loaded in a different session from the one used for writes.session.merge(ti)then cascaded the staleQUEUEDDagRun back over theFAILEDstate thatcancel_task_instanceshad just set. It now loads both in its own session. This was hidden on 2.5.1 because A3'sTypeErrorfired first.Tests
tests/www/api/experimental/: 34 passed (Python 3.9.18,constraints-2.9.3/constraints-3.9.txt).test_cancel_clear_dag_run_endpoints.pycovers cancel and clear, including RUNNING TI →SHUTDOWNwith its job shut down, and the A3 finished-run regression.dag_runstests for thedagrun_idandexecution_date_gtefilters, plus the bad-date 400.toggle_dag_hookfires on pause.test_trigger_dagnow asserts the audit row. I removed its zero-microsecond assertion, because the fork setsexecution_datebeforereplace_microsecondsis derived (unchanged from2.5.1+affirm4).Related upstream tests for DAG pause, trigger and delete, and
tests/api/common/: 17 passed.Downstream validation: the airflow-att unit suite was run against upstream 2.9.3 with this PR's
airflow/patches applied (DT pins from plan §6.1): 969/974 with Affirm/all-the-things#236129. The 5 remaining failures areAffirmDAGstart_datecases unrelated to these patches.CI: this fork only has upstream Apache's workflows. Their
Build Infojob never gets a runner here (it was cancelled after 24h without running), so the results above are from local runs.Open items
/api/experimental/dags/<id>/cancel_dag_runhave a live caller? Inall-the-things,platform/batch/live/.../task_scheduler_client.py:196definescancel_dagrun(), but only its unit test calls it. Callers outside that repo still need confirmation. Today the endpoint always returns 500 (A3), so any caller would start seeing successful cancels.2.9.3+affirm1. That tag unblocks BATCH-4365, which builds and publishes the wheel.🤖 Generated with Claude Code