-
-
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
Yet another attempt to solve TTC errors... #203
Conversation
Reviewer's Guide by SourceryThis pull request refactors the way accelerometer data is saved and processed in ShakeTune. It introduces a dedicated writer process to handle disk writes, which prevents blocking I/O and improves performance. The changes also simplify the graph creation process and ensure that data is saved correctly. Sequence diagram for saving accelerometer datasequenceDiagram
participant ST as ShakeTune
participant MM as MeasurementsManager
participant WP as WriterProcess
participant Queue as WriterQueue
participant Disk
ST->>MM: add_measurement(name, samples)
alt len(measurements) > chunk_size
MM->>Queue: put(measurement)
activate WP
Queue->>WP: meas
WP->>Disk: write(meas)
deactivate WP
end
ST->>MM: save_stdata(filename)
MM->>Queue: put(STOP_SENTINEL)
WP->>Disk: flush()
Disk-->>WP: done
WP-->>MM: done
MM-->>ST: done
Updated class diagram for MeasurementsManagerclassDiagram
class MeasurementsManager {
-chunk_size: int
-k_reactor
-measurements: List~Measurement~
-temp_file: Path
-writer_queue: Queue
-is_writing: Value
-writer_process: Optional~Process~
+__init__(chunk_size: int, k_reactor=None)
+clear_measurements(keep_last: bool = False)
+append_samples_to_current_measurement(additional_samples: SamplesList)
+add_measurement(name: str, samples: SamplesList = None, timeout: float = 30)
-_writer_loop(output_file: Path, write_queue: Queue, is_writing: Value)
-_flush_chunk()
+save_stdata(filename: Path, timeout: int = 30)
+get_measurements() : List~Measurement~
+load_from_stdata(filename: Path) : List~Measurement~
+load_from_csvs(klipper_CSVs: List~Path~) : List~Measurement~
+__del__()
}
class Measurement {
name: str
samples: List~Sample~
}
Measurement -- MeasurementsManager: contains
note for MeasurementsManager "Manages accelerometer measurements, including writing to disk using a dedicated process."
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 adding a method to
MeasurementsManager
to check if the writer process is running. - The
__del__
method inMeasurementsManager
might not always be called, so consider a more explicit cleanup mechanism.
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary by Sourcery
Refactor the accelerometer data saving mechanism to use a dedicated writer process and queue. This prevents blocking I/O operations and improves data integrity. Update the data format to JSON lines for improved handling and parsing. Modify the
shaketune_process.py
to accept filenames as input and load data accordingly. Update graph creation to use the new data loading mechanism and save graphs with consistent naming. Fix various bugs related to data handling and analysis, and improve error handling and reporting.Bug Fixes:
Enhancements: