Skip to content

Conversation

@kaxil
Copy link
Member

@kaxil kaxil commented Oct 22, 2025

Replace version-specific conditional imports with common.compat layer. This standardizes compatibility handling across Airflow 2.x and 3.x.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@potiuk
Copy link
Member

potiuk commented Oct 22, 2025

Compat failing on missing next_dagrun_info ?

Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compat failing on missing next_dagrun_info ?

Yes, since after the change we will import airflow.sdk.DAG for AIRFLOW_V_3_0_PLUS, but we need to import airflow.models.DAG to make the following Dag setup works.

bundle_name = "testing"
if AIRFLOW_V_3_1_PLUS:
sync_dag_to_db(dag, bundle_name=bundle_name, session=session)
elif AIRFLOW_V_3_0_PLUS:
from airflow.models.dagbundle import DagBundleModel
from airflow.models.serialized_dag import SerializedDagModel
from airflow.serialization.serialized_objects import SerializedDAG
session.add(DagBundleModel(name=bundle_name))
session.flush()
SerializedDAG.bulk_write_to_db(bundle_name, None, [dag])
SerializedDagModel.write_dag(dag, bundle_name=bundle_name)

So maybe we could rewrite the test to just setup the TI instead of the whole Dag like TestGCSTaskHandler one:

def task_instance(self, create_task_instance, session):
self.ti = ti = create_task_instance(
dag_id="dag_for_testing_gcs_task_handler",
task_id="task_for_testing_gcs_task_handler",
logical_date=datetime(2020, 1, 1),
state=TaskInstanceState.RUNNING,
)
ti.try_number = 1
ti.raw = False
session.add(ti)
session.commit()
yield
clear_db_runs()
clear_db_dags()

@jason810496 jason810496 self-assigned this Oct 22, 2025
@jason810496
Copy link
Member

I can help out rewrite the test tomorrow if this is not very urgent

Replace version-specific conditional imports with common.compat layer.
This standardizes compatibility handling across Airflow 2.x and 3.x.
@kaxil kaxil force-pushed the migrate-redis-provider branch from a3ea4e0 to 36a0de7 Compare October 22, 2025 11:44
@kaxil
Copy link
Member Author

kaxil commented Oct 22, 2025

This works. Failure is unrelated -- its a transient mongo error

@kaxil kaxil merged commit ad80963 into apache:main Oct 22, 2025
86 of 87 checks passed
@kaxil kaxil deleted the migrate-redis-provider branch October 22, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants