Commits
Click on a commit to change the comparison rangeAdd 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>2 months ago
by chrisguidry Update auto-generated documentation for NonNegativeTimeDelta type2 months ago
by chrisguidry