Skip to content

Refactor bundle refresh persistence into overridable get/update methods#63835

Merged
ephraimbuddy merged 3 commits intoapache:mainfrom
astronomer:refactor-bundle-refresh-persistence
Mar 25, 2026
Merged

Refactor bundle refresh persistence into overridable get/update methods#63835
ephraimbuddy merged 3 commits intoapache:mainfrom
astronomer:refactor-bundle-refresh-persistence

Conversation

@ephraimbuddy
Copy link
Copy Markdown
Contributor

Replace inline DagBundleModel mutations in _refresh_dag_bundles() with get_bundle_state() and update_bundle_state() instance methods on DagFileProcessorManager, isolating all DB access for bundle state behind a clean override seam.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Sonnet 4.6

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors DAG bundle refresh persistence in DagFileProcessorManager._refresh_dag_bundles() by moving direct DagBundleModel mutations into two new instance methods (get_bundle_state() and update_bundle_state()), creating a clean override seam for DB access and adding unit tests for the new behavior.

Changes:

  • Introduce BundleState and DagFileProcessorManager.get_bundle_state() / update_bundle_state() to encapsulate persisted bundle refresh state.
  • Update _refresh_dag_bundles() to use the new methods (including error-handling paths) instead of inline session usage.
  • Add unit tests covering state read/write behavior and refresh loop interactions via mocked get/update methods.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
airflow-core/src/airflow/dag_processing/manager.py Adds BundleState + get/update persistence methods; refactors _refresh_dag_bundles() to call them.
airflow-core/tests/unit/dag_processing/test_manager.py Adds unit tests for the new persistence methods and refresh loop behavior.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors how DagFileProcessorManager._refresh_dag_bundles() reads/writes persisted DAG bundle refresh state by introducing overridable get_bundle_state() / update_bundle_state() methods, providing a cleaner seam for isolating DB access.

Changes:

  • Add a BundleState type plus get_bundle_state() / update_bundle_state() methods on DagFileProcessorManager.
  • Refactor _refresh_dag_bundles() to use those methods (and to log/continue on state read/write failures).
  • Add unit tests covering the new methods and key _refresh_dag_bundles() state/persistence behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
airflow-core/src/airflow/dag_processing/manager.py Introduces BundleState and new DB access methods; updates bundle refresh loop to use them.
airflow-core/tests/unit/dag_processing/test_manager.py Adds unit tests for bundle state get/update and refresh persistence paths.

Replace inline DagBundleModel mutations in _refresh_dag_bundles() with
get_bundle_state() and update_bundle_state() instance methods on
DagFileProcessorManager, isolating all DB access for bundle state
behind a clean override seam.
@ephraimbuddy ephraimbuddy force-pushed the refactor-bundle-refresh-persistence branch from 6fd9973 to 3ecabaf Compare March 25, 2026 10:46
@ephraimbuddy ephraimbuddy requested a review from kaxil March 25, 2026 10:51
@ephraimbuddy ephraimbuddy merged commit 326680f into apache:main Mar 25, 2026
80 checks passed
@ephraimbuddy ephraimbuddy deleted the refactor-bundle-refresh-persistence branch March 25, 2026 14:53
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