-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
spliting stdata into chunks on the filesystem #155
Conversation
with all the logic to load them back and reconstruct the .stdata file
Reviewer's Guide by SourceryThis pull request implements a chunking mechanism for storing accelerometer data on the filesystem. It introduces a new approach to handle large amounts of measurement data by splitting it into smaller chunks, saving them temporarily, and reassembling them when needed. This change aims to improve memory management and performance when dealing with extensive accelerometer data. File-Level Changes
Tips
|
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.
Hey @Frix-x - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider making CHUNK_SIZE configurable or based on system resources for optimal performance across different environments.
- It would be beneficial to add unit tests for the new methods introduced, particularly _save_chunk, _reassemble_chunks, and _load_measurements_from_file.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
|
||
def _save_to_file(self, filename: Path): | ||
def _reassemble_chunks(self, filename: Path): |
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.
suggestion (bug_risk): Improve error handling in _reassemble_chunks method
If an exception occurs during the reassembly process, the method catches the exception and prints a warning, but it doesn't clean up the temporary files or reset the state. This could lead to inconsistent state and leftover temporary files. Consider adding cleanup code in the exception handler.
def _reassemble_chunks(self, filename: Path):
try:
os.nice(19)
# Existing reassembly code here
except Exception as e:
logging.warning(f"Error during chunk reassembly: {e}")
self._cleanup_temp_files()
self._reset_state()
raise
finally:
self._cleanup_temp_files()
if keep_last: | ||
self.measurements = [self.measurements[-1]] | ||
else: | ||
self.measurements = [] |
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.
suggestion (code-quality): Replace if statement with if expression (assign-if-exp
)
if keep_last: | |
self.measurements = [self.measurements[-1]] | |
else: | |
self.measurements = [] | |
self.measurements = [self.measurements[-1]] if keep_last else [] |
except Exception: | ||
pass # Ignore errors as it's not critical | ||
try: | ||
all_measurements = [] |
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.
issue (code-quality): Extract code out into method (extract-method
)
with all the logic to load them back and reconstruct the .stdata file
Summary by Sourcery
Split measurement data into chunks to optimize memory usage and implement logic to reassemble these chunks into a complete data file. Introduce a method to ensure data transfers are completed before proceeding, and enhance resource management by cleaning up temporary files.
New Features:
Enhancements:
Chores: