PrefectHQ
prefect
BlogDocsChangelog

Add schedule_after field to RunDeployment action for delayed execution

#18801Merged
Comparing
scheduled-run-deployment-action
(
19cd2af
) with
main
(
aa4f5d0
)
CodSpeed Performance Gauge
0%
Untouched
2
Ignored
6

Benchmarks

Passed

bench_task_decorator
benches/bench_tasks.py
CodSpeed Performance Gauge
0%
460.5 µs460.5 µs
bench_import_prefect_flow
benches/bench_import.py
CodSpeed Performance Gauge
0%
1.4 s1.4 s

Ignored

bench_flow_decorator
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+2%
4.3 ms4.2 ms
bench_flow_call[options1]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
0%
106.1 ms106 ms
bench_import_prefect
benches/bench_import.py
Ignored
CodSpeed Performance Gauge
0%
2.7 ms2.7 ms
bench_task_call
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
-1%
170.2 ms172.8 ms
bench_flow_call[options0]
benches/bench_flows.py
Ignored
CodSpeed Performance Gauge
+2%
168.3 ms165 ms
bench_task_submit
benches/bench_tasks.py
Ignored
CodSpeed Performance Gauge
+14%
5.3 ms4.7 ms

Commits

Click on a commit to change the comparison range
Base
main
aa4f5d0
-0.05%
Add schedule_after field to RunDeployment action for delayed execution This change adds support for scheduling deployment runs to execute after a specified delay, enabling opt-out workflow patterns where automated actions can be cancelled before execution. - **Server-side RunDeployment action**: Added `schedule_after: timedelta` field with default `timedelta(0)` for backwards compatibility - **Client-side RunDeployment action**: Added matching `schedule_after` field for schema consistency - **Field validation**: Reject negative delays with clear error messages - **Time calculation**: Use `datetime.now(timezone.utc) + self.schedule_after` for consistent timezone handling - **BaseDeploymentTrigger**: Added `schedule_after` field to enable YAML configuration - **Automation creation**: Updated `actions()` method to pass through `schedule_after` when creating RunDeployment actions - **YAML support**: Field works seamlessly in `prefect.yaml`, `flow.serve()`, and `flow.deploy()` contexts - **Comprehensive test suite**: Tests default behavior, validation, time formats (seconds, ISO 8601), and actual delayed scheduling - **DeploymentTrigger tests**: Verify integration between triggers and actions - **Backwards compatibility**: All existing tests pass, no breaking changes - **Schema compatibility**: Fixed serialization tests to handle new field - **Usage examples**: Added examples for `prefect.yaml`, `flow.serve()`, and `flow.deploy()` - **Use cases**: Documented opt-out campaigns and delayed execution patterns - **Field formats**: Documented support for ISO 8601 durations, seconds, and timedelta objects ```yaml triggers: - type: event expect: ["campaign.created"] schedule_after: "PT2H" # Wait 2 hours before execution ``` ```python trigger = DeploymentEventTrigger( expect=["event.name"], schedule_after=timedelta(hours=1) ) ``` Closes #18331 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
84b4d61
2 months ago
by chrisguidry
-0.02%
Update auto-generated documentation for NonNegativeTimeDelta type
19cd2af
2 months ago
by chrisguidry
© 2025 CodSpeed Technology
Home Terms Privacy Docs