Repository navigation
Sync with dev 0830 - #5
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR synchronizes changes from the dev branch, focusing on refactoring the data storage system to improve data handling efficiency and code organization. The changes replace the previous row/column-based data structure with a more structured approach using global/local indexes and column data dictionaries.
Key changes include:
- Refactored data storage structure from row/column-based to global/local index-based approach
- Added new StorageUnitData class for improved data management
- Removed unused PUT_FULL_ERROR enum value and simplified response structures
Reviewed Changes
Copilot reviewed 3 out of 21 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| transfer_queue/zmq_utils.py | Removes unused PUT_FULL_ERROR enum value |
| transfer_queue/data_system.py | Major refactoring of data storage system with new StorageUnitData class and improved data handling |
| recipe/simple_use_case/start_transferqueue.py | Minor adjustments to parent directory path and sleep timing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| """ | ||
| def __init__(self, storage_size: int): | ||
| # Dict containing column names and corresponding data in the column (e.g. {"column_name1": [data1, data2, ...]}) | ||
| self.column_data: Dict[str: List] = {} |
There was a problem hiding this comment.
The type annotation syntax is incorrect. It should be Dict[str, List] instead of Dict[str: List] (missing comma).
| self.column_data: Dict[str: List] = {} | |
| self.column_data: Dict[str, List] = {} |
| # Number of elements stored in storage unit | ||
| self.storage_size = storage_size | ||
|
|
||
| def get_data(self, columns: List[str], local_indexes: List[int]) -> TensorDict[str, List]: |
There was a problem hiding this comment.
The return type annotation TensorDict[str, List] is inconsistent. Based on the implementation, it should return TensorDict without generic parameters, as TensorDict is being used as a constructor in the return statement.
| def get_data(self, columns: List[str], local_indexes: List[int]) -> TensorDict[str, List]: | |
| def get_data(self, columns: List[str], local_indexes: List[int]) -> TensorDict: |
|
|
||
| for col in columns: | ||
| if len(local_indexes) == 1: | ||
| result[col] = list(self.column_data[col][local_indexes[0]]) |
There was a problem hiding this comment.
When len(local_indexes) == 1, wrapping the result in list() may cause unexpected behavior if self.column_data[col][local_indexes[0]] is already a single item rather than an iterable. This could raise a TypeError.
| result[col] = list(self.column_data[col][local_indexes[0]]) | |
| result[col] = [self.column_data[col][local_indexes[0]]] |
| self.data_production_status[indexes, [self.column_name_mapping.get(col) for col in columns]] = 1 | ||
|
|
There was a problem hiding this comment.
The indexes parameter should be converted to a tensor and the column mapping list should handle potential None values. If any column is not in the mapping, get() returns None which will cause indexing errors.
| self.data_production_status[indexes, [self.column_name_mapping.get(col) for col in columns]] = 1 | |
| # Convert indexes to tensor if not already | |
| if not isinstance(indexes, torch.Tensor): | |
| indexes_tensor = torch.tensor(indexes, dtype=torch.long, device=self.data_production_status.device) | |
| else: | |
| indexes_tensor = indexes | |
| column_indices = [self.column_name_mapping.get(col) for col in columns] | |
| if any(idx is None for idx in column_indices): | |
| missing = [col for col, idx in zip(columns, column_indices) if idx is None] | |
| raise ValueError(f"Columns not found in column_name_mapping: {missing}") | |
| self.data_production_status[indexes_tensor, column_indices] = 1 |
… (#5) * docs: improve docstrings for clarity and consistency across client.py * Update transfer_queue/client.py Co-authored-by: Copilot <[email protected]> * fix comments * fix comments --------- Co-authored-by: liuximeng <[email protected]> Co-authored-by: Han Zhenyu 韩振宇 <[email protected]> Co-authored-by: Copilot <[email protected]>
No description provided.