[BREAKING][Feat] Add fine-grained clear method & optimize log#159
Conversation
Signed-off-by: 0oshowero0 <[email protected]>
Signed-off-by: 0oshowero0 <[email protected]>
Signed-off-by: 0oshowero0 <[email protected]>
Signed-off-by: 0oshowero0 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughThis PR refactors the transfer queue client and controller APIs, renaming Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces a breaking change that adds fine-grained clearing capabilities to the TransferQueue system. The main change renames the existing clear() method to clear_partition() for clarity and adds a new clear_samples() method that allows clearing specific samples while preserving the partition.
Key changes:
- Renamed
clear()toclear_partition()in both client and controller - Added
clear_samples()method for fine-grained sample clearing - Refactored ZMQ request types (renamed
GET_CLEAR_METAtoGET_PARTITION_META, addedCLEAR_PARTITIONseparate fromCLEAR_META) - Updated
PartitionIndexManagerwith newrelease_partition()andrelease_indexes()methods - Reduced default thread count from 16 to 8 in
TQ_NUM_THREADS
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| transfer_queue/controller.py | Added clear_meta() method for sample-level clearing, renamed clear() to clear_partition(), refactored index manager with separate release methods |
| transfer_queue/client.py | Renamed clear() to clear_partition(), added clear_samples() method, refactored internal helper methods to distinguish partition vs sample clearing |
| transfer_queue/utils/zmq_utils.py | Renamed and added ZMQ request types to distinguish partition-level vs sample-level operations |
| transfer_queue/storage/simple_backend.py | Changed default TQ_NUM_THREADS from 16 to 8 |
| tests/test_controller.py | Added test for clear_meta() functionality, updated tests to use renamed clear_partition() |
| tests/test_client.py | Added comprehensive tests for both clear_partition() and clear_samples() methods, updated mock controller to handle new request types |
| tutorial/*.py | Updated all tutorial examples to use renamed clear_partition() method |
| recipe/simple_use_case/*.py | Updated demo files to use renamed clear_partition() method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await self._clear_partition_in_controller(partition_id) | ||
|
|
||
| # Clear storage unit data | ||
| await self.storage_manager.clear_data(metadata) |
There was a problem hiding this comment.
Operation ordering issue: The partition is cleared in the controller (line 413) before clearing storage (line 416). If the storage clear operation fails, the controller metadata has already been cleared, leaving the system in an inconsistent state. Consider either clearing storage first, or implementing a rollback mechanism, or at minimum documenting this behavior in the method's docstring.
| # Clear the controller metadata | ||
| await self._clear_meta_in_controller(metadata) | ||
|
|
||
| # Clear storage unit data | ||
| await self.storage_manager.clear_data(metadata) | ||
|
|
There was a problem hiding this comment.
Operation ordering issue: Samples are cleared in the controller (line 442) before clearing storage (line 445). If the storage clear operation fails, the controller metadata has already been cleared, leaving the system in an inconsistent state. Consider either clearing storage first, or implementing a rollback mechanism, or at minimum documenting this behavior in the method's docstring.
| # Clear the controller metadata | |
| await self._clear_meta_in_controller(metadata) | |
| # Clear storage unit data | |
| await self.storage_manager.clear_data(metadata) | |
| # Clear storage unit data first | |
| await self.storage_manager.clear_data(metadata) | |
| # Clear the controller metadata | |
| await self._clear_meta_in_controller(metadata) |
Signed-off-by: 0oshowero0 <[email protected]>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if not self._controller: | ||
| raise RuntimeError("No controller registered") | ||
|
|
There was a problem hiding this comment.
Consider adding validation to check if metadata is empty (no samples) before proceeding with the clear operation. While the controller's clear_meta can handle empty lists safely, it's more efficient and clearer to validate and potentially short-circuit early or log a warning when clearing with empty metadata.
| # Short-circuit if metadata contains no samples to clear | |
| if ( | |
| not getattr(metadata, "global_indexes", None) | |
| and not getattr(metadata, "partition_ids", None) | |
| ): | |
| logger.debug( | |
| f"[{self.client_id}]: Skipping clear_samples; received empty metadata." | |
| ) | |
| return |
Signed-off-by: 0oshowero0 <[email protected]>
Signed-off-by: 0oshowero0 <[email protected]>
async_clear_partition(previous clear) andasync_clear_samplesmethod for client. Through theasync_clear_samplesinterface, we can let user to clear specific samples rather than determine the whole partition.TQ_NUM_THREADSto 8.Summary by CodeRabbit
New Features
clear_samples()method to selectively clear specific data samples within a partition.Documentation
Chores
clear()method toclear_partition()for improved clarity on partition-level operations.✏️ Tip: You can customize this high-level summary in your review settings.