Skip to content

Allow custom partition Window subclasses via plugin registry#68717

Merged
Lee-W merged 2 commits into
apache:mainfrom
astronomer:custom-window-plugin-registry
Jun 22, 2026
Merged

Allow custom partition Window subclasses via plugin registry#68717
Lee-W merged 2 commits into
apache:mainfrom
astronomer:custom-window-plugin-registry

Conversation

@Lee-W

@Lee-W Lee-W commented Jun 18, 2026

Copy link
Copy Markdown
Member

Why

Today custom Window subclasses are rejected at serialization with WindowNotSupported — only the 7 builtins work.

closes: #65756

What

A custom-window plugin registry, mirroring the existing custom-timetable / partition_mapper ones:

  • windows list attribute on AirflowPlugin (windows = [MyWindow]).
  • @cached get_windows_plugins() collector.
  • find_registered_custom_window() in serialization/helpers.py.
  • encode_window / decode_window now look non-core paths up in the registry (builtin fast-path unchanged); unregistered paths still raise WindowNotSupported and are never handed to import_string.

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

Generated-by: [Claude] following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@Lee-W Lee-W added the backport-to-v3-3-test Backport to v3-3-test label Jun 18, 2026
@Lee-W Lee-W marked this pull request as ready for review June 18, 2026 14:38
@Lee-W Lee-W requested a review from jason810496 June 18, 2026 14:38
@Lee-W Lee-W added this to the Airflow 3.3.0 milestone Jun 19, 2026

@FrankYang0529 FrankYang0529 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. One minor suggestion: do we want to add a custom window example to example_dags/plugins/?

@Lee-W Lee-W force-pushed the custom-window-plugin-registry branch from 870a987 to 51f854c Compare June 22, 2026 01:01
@Lee-W

Lee-W commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

sounds like a good idea! I didn't even know we have that. Thanks!

@phanikumv phanikumv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI failing for the below reasons:-

In airflow-core/tests/unit/plugins/test_plugins_manager.py#L82

The new business_day_window.py example plugin makes this 11, not 10 — this is what's failing CI (assert 11 == 10).

assert len(plugins) == 11

In airflow-core/tests/unit/plugins/test_plugins_manager.py#L105

Same cause here, now four examples load, not three (assert 4 == 3). Bump the count and the comment.

assert len(plugins) == 4 # four are loaded from examples

@Lee-W Lee-W self-assigned this Jun 22, 2026
@Lee-W Lee-W force-pushed the custom-window-plugin-registry branch 2 times, most recently from cb62c2d to 457fe26 Compare June 22, 2026 09:13
Comment thread airflow-core/tests/unit/plugins/test_plugins_manager.py Outdated
Lee-W added 2 commits June 22, 2026 18:18
Custom ``Window`` subclasses can now be registered on
``AirflowPlugin.windows``, serialized by import path, and run
scheduler-side — mirroring custom timetables and partition mappers.
This lets users implement calendar-aware rollup completeness (business
days, holidays) as a user-land window instead of waiting on raw clock
coverage.

Unregistered non-core import paths are still rejected with
``WindowNotSupported``; the deserializer never imports an unregistered
path. Newsfragment pending PR number.
Demonstrate registering a calendar-aware Window subclass via
AirflowPlugin.windows, mirroring the existing custom priority-weight
strategy example.
@Lee-W Lee-W force-pushed the custom-window-plugin-registry branch from 457fe26 to 01c35aa Compare June 22, 2026 10:19
@Lee-W

Lee-W commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

CI failing for the below reasons:-

In airflow-core/tests/unit/plugins/test_plugins_manager.py#L82

The new business_day_window.py example plugin makes this 11, not 10 — this is what's failing CI (assert 11 == 10).

assert len(plugins) == 11

In airflow-core/tests/unit/plugins/test_plugins_manager.py#L105

Same cause here, now four examples load, not three (assert 4 == 3). Bump the count and the comment.

assert len(plugins) == 4 # four are loaded from examples

thanks, just fixed

@Lee-W Lee-W merged commit 47dab8b into apache:main Jun 22, 2026
82 checks passed
@Lee-W Lee-W deleted the custom-window-plugin-registry branch June 22, 2026 11:28
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-3-test PR Link

Lee-W added a commit that referenced this pull request Jun 22, 2026
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.

Rollup: calendar-aware completeness (business days, holidays)

4 participants