-
Notifications
You must be signed in to change notification settings - Fork 0
feat: populate failed_work_units with error details and remove S3 restrictions #99
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5fd8d46
Rewrite tests for WorkUnit-based reaping
zhexuany 80cad3d
feat: populate failed_work_units with error details in batch status
zhexuany f3bb63a
fix: address code review feedback
zhexuany 6524a26
fix: address remaining code review feedback from Kilo
zhexuany File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
crates/roboflow-distributed/tests/test_controller_new.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| // SPDX-FileCopyrightText: 2026 ArcheBase | ||
| // | ||
| // SPDX-License-Identifier: MulanPSL-2.0 | ||
|
|
||
| //! Integration test for failed_work_units population in batch status. | ||
|
|
||
| use roboflow_distributed::batch::{ | ||
| BatchController, BatchIndexKeys, BatchKeys, BatchPhase, BatchSpec, BatchStatus, WorkFile, | ||
| WorkUnit, WorkUnitKeys, WorkUnitStatus, | ||
| }; | ||
| use roboflow_distributed::tikv::client::TikvClient; | ||
| use std::sync::Arc; | ||
|
|
||
| fn unique_batch_id(prefix: &str) -> String { | ||
| format!("jobs:{}-{}", prefix, uuid::Uuid::new_v4()) | ||
| } | ||
|
|
||
| async fn get_tikv_client() -> Option<Arc<TikvClient>> { | ||
| match TikvClient::from_env().await { | ||
| Ok(client) => Some(Arc::new(client)), | ||
| Err(e) => { | ||
| println!("Skipping test: TiKV not available: {}", e); | ||
| None | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_reconcile_populates_failed_work_units_with_error_details() { | ||
| //! Verify that reconcile populates failed_work_units with error details. | ||
| //! | ||
| //! This tests the fix for the issue where work unit failures showed no error | ||
| //! details in batch status output. | ||
| let tikv = match get_tikv_client().await { | ||
| Some(client) => client, | ||
| None => return, | ||
| }; | ||
| let controller = BatchController::with_client(tikv.clone()); | ||
|
|
||
| let batch_id = unique_batch_id("test-failed-work-units"); | ||
| let batch_name = batch_id.strip_prefix("jobs:").unwrap(); | ||
|
|
||
| // Create batch | ||
| let spec = BatchSpec::new( | ||
| batch_name, | ||
| vec!["s3://test/file.bag".to_string()], | ||
| "s3://output/".to_string(), | ||
| ); | ||
| controller.submit_batch(&spec).await.unwrap(); | ||
|
|
||
| // Create work units: one complete, one failed with error | ||
| let complete_unit_id = "unit-complete"; | ||
| let failed_unit_id = "unit-failed"; | ||
| let error_message = "Test error: codec failure"; | ||
|
|
||
| // Create complete work unit | ||
| let mut complete_unit = WorkUnit::with_id( | ||
| complete_unit_id.to_string(), | ||
| batch_id.to_string(), | ||
| vec![WorkFile::new("s3://test/file1.bag".to_string(), 1024)], | ||
| "s3://output/".to_string(), | ||
| "config-hash".to_string(), | ||
| ); | ||
| complete_unit.status = WorkUnitStatus::Complete; | ||
|
|
||
| // Create failed work unit with error | ||
| let mut failed_unit = WorkUnit::with_id( | ||
| failed_unit_id.to_string(), | ||
| batch_id.to_string(), | ||
| vec![WorkFile::new("s3://test/file2.bag".to_string(), 2048)], | ||
| "s3://output/".to_string(), | ||
| "config-hash".to_string(), | ||
| ); | ||
| failed_unit.status = WorkUnitStatus::Dead; | ||
| failed_unit.error = Some(error_message.to_string()); | ||
| failed_unit.attempts = 3; | ||
|
|
||
| // Store work units in TiKV | ||
| let complete_key = WorkUnitKeys::unit(&batch_id, complete_unit_id); | ||
| let failed_key = WorkUnitKeys::unit(&batch_id, failed_unit_id); | ||
| tikv.put( | ||
| complete_key.clone(), | ||
| bincode::serialize(&complete_unit).unwrap(), | ||
| ) | ||
| .await | ||
| .unwrap(); | ||
| tikv.put( | ||
| failed_key.clone(), | ||
| bincode::serialize(&failed_unit).unwrap(), | ||
| ) | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| // Transition batch to Running phase | ||
| let mut status = BatchStatus::new(); | ||
| status.transition_to(BatchPhase::Running); | ||
| status.set_work_units_total(2); | ||
| let status_key = BatchKeys::status(&batch_id); | ||
| tikv.put(status_key.clone(), bincode::serialize(&status).unwrap()) | ||
| .await | ||
| .unwrap(); | ||
|
|
||
| // Trigger reconciliation using public API | ||
| let result = controller.reconcile_batch_id(&batch_id).await; | ||
| assert!(result.is_ok(), "Reconciliation should succeed"); | ||
|
|
||
| // Get updated status | ||
| let updated_status = controller | ||
| .get_batch_status(&batch_id) | ||
| .await | ||
| .unwrap() | ||
| .unwrap(); | ||
|
|
||
| // Verify failed_work_units is populated | ||
| assert_eq!( | ||
| updated_status.failed_work_units.len(), | ||
| 1, | ||
| "Should have one failed work unit" | ||
| ); | ||
|
|
||
| let failed = &updated_status.failed_work_units[0]; | ||
| assert_eq!(failed.id, failed_unit_id); | ||
| assert_eq!(failed.source_file, "s3://test/file2.bag"); | ||
| assert_eq!(failed.error, error_message); | ||
| assert_eq!(failed.retries, 3); | ||
|
|
||
| // Verify counts | ||
| assert_eq!(updated_status.work_units_completed, 1); | ||
| assert_eq!(updated_status.work_units_failed, 1); | ||
|
|
||
| // Cleanup | ||
| let _ = tikv.delete(BatchKeys::spec(&batch_id)).await; | ||
| let _ = tikv.delete(BatchKeys::status(&batch_id)).await; | ||
| let _ = tikv.delete(complete_key).await; | ||
| let _ = tikv.delete(failed_key).await; | ||
| let _ = tikv | ||
| .delete(BatchIndexKeys::phase(BatchPhase::Pending, &batch_id)) | ||
| .await; | ||
| let _ = tikv | ||
| .delete(BatchIndexKeys::phase(BatchPhase::Running, &batch_id)) | ||
| .await; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed work units where
unit.errorisNoneget counted in thefailedtally but are silently excluded fromfailed_work_units. This meansstatus.work_units_failedcan exceedstatus.failed_work_units.len(), which is confusing for users -- they see "N work units failed" but fewer than N entries with details. Since the whole point of this change is error visibility, it would be better to always push aFailedWorkUnitentry, using a fallback like"No error details available"whenunit.errorisNone.Fix it with Roo Code or mention @roomote and request a fix.