- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2k
          Add end_time filters for flow runs and task runs
          #19107
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adds end_time filtering capability to FlowRunFilter and TaskRunFilter, allowing users to query for runs that finished before/after a specific time or that haven't finished yet (is_null). This completes the time-based filtering API by providing end_time filters that match the existing start_time filter patterns. Closes #9698 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| CodSpeed Performance ReportMerging #19107 will not alter performanceComparing  Summary
 | 
| @claude revert the current test changes and add tests covering the changes in this PR to  | 
| Claude finished @desertaxle's task —— View job Completed ✓
 SummaryI've successfully moved the end_time filter tests from the schema test file to the models test file: Reverted changes in  
 Added tests in  
 These tests follow the existing pattern in the models test file and will run through all 4 test methods (python client, models count, models read, and API endpoints) for comprehensive coverage. | 
- Reverted test changes in tests/server/schemas/test_filters.py - Added end_time filter tests to tests/server/models/test_filters.py - Tests cover both FlowRun and TaskRun end_time filters with is_null_ checks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Alex Streed <[email protected]>
| @claude can you add tests also covering the  | 
| Claude finished @desertaxle's task —— View job Completed ✓
 SummaryI've successfully added test coverage for the  FlowRun end_time filters (added 2 test cases): 
 TaskRun end_time filters (added 2 test cases): 
 These tests follow the same parameterized testing pattern already in use and will run through all 4 test methods (Python client, models count, models read, and API endpoints) for comprehensive coverage. | 
Add test coverage for before_ and after_ options on both FlowRunFilterEndTime and TaskRunFilterEndTime to ensure these filter options work correctly. Co-authored-by: Alex Streed <[email protected]>
| @claude fix the failing server tests | 
| Claude finished @desertaxle's task —— View job Completed ✓
 Root CauseThe  The test data was creating flow runs and task runs with Completed/Failed states but without  
 Fix AppliedAdded  Changed: 
 The tests should now pass because: 
 | 
The end_time field is automatically set by the orchestration layer only when a run enters a final state AND has a start_time set. The test data was creating flow runs and task runs with Completed/Failed states but without start_time, causing end_time to never be set. This commit adds start_time to all flow runs and task runs with terminal states (Completed, Failed) in the test fixture data, ensuring that end_time gets properly set by the orchestration layer. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Alex Streed <[email protected]>
end_time filters for flow runs and task runs
      
closes #9698
This PR adds end_time filtering capability to FlowRunFilter and TaskRunFilter, allowing users to query for runs that finished before/after a specific time or that haven't finished yet.
Changes
Client-side schemas (
src/prefect/client/schemas/filters.py):FlowRunFilterEndTimeclassend_timefield toFlowRunFilterTaskRunFilterEndTimeclassend_timefield toTaskRunFilterServer-side schemas (
src/prefect/server/schemas/filters.py):TaskRunFilterEndTimeclass with SQL filter implementationend_timefield toTaskRunFilterend_timefilter check inTaskRunFilter._get_filter_list()Tests (
tests/server/schemas/test_filters.py):TaskRunFilterEndTime:test_applies_task_run_end_time_filter_beforetest_applies_task_run_end_time_filter_aftertest_applies_task_run_end_time_filter_nullThe implementation follows the existing patterns for
start_timefilters and provides the same functionality (before_,after_,is_null_) for filtering byend_time.All existing tests pass, and the new filters work as expected with the API.