Skip to content

Fixes to avoid data loss#98

Open
deruyter92 wants to merge 4 commits into
cy/TEST-unity-procfrom
jaap/experimental-fixes
Open

Fixes to avoid data loss#98
deruyter92 wants to merge 4 commits into
cy/TEST-unity-procfrom
jaap/experimental-fixes

Conversation

@deruyter92

Copy link
Copy Markdown
Contributor

Summary
Two defensive fixes on the GUI side to prevent silently losing processor
outputs when the DLC processor shuts down before the recording-stopped
hook fires.

The custom processor plugin dlc_inference_w_pd_sync saves its legacy
outputs (PROC pickle, DLC HDF5, timestamp NPY) and performs DB-compatible
file copies through on_recording_stopped().

some non-standard ways of ending the experiment could bypass
this hook

  1. Any closeEvent: the shutdown skipped _cleanup_processor() when the worker thread
    stopped cleanly. After Fix thread crash in TeensyLatency + prevent data-loss for dlc_inference_w_pd_sync MMathisLab/FreelyMovingVR4Mice#329, the processor should now save it's own data when stopping. So cleanup of the processor is good here and safe.

  2. Stop inference while recording: _stop_inference() stops
    the processor via _dlc.reset() before the recording stops. When recording is later stopped,
    _notify_processor_recording_stopped() finds no processor instance.

changes:

  1. Add the missing self._cleanup_processor() call in the clean-shutdown
    branch of shutdown(), so that processor resources are properly released
    and (with the processor-side fix) data is saved before the window closes.
  2. When the user clicks "Stop inference" while recording is active, a
    QMessageBox.question dialog now appears warning that legacy output
    copies will be skipped and recommending to stop recording first. If the
    user proceeds anyway, the processor saves its core data through its own
    stop() path. No prompt appears when recording is not active.

… during recording

When the user clicks "Stop pose inference" before "Stop recording",
the processor instance was destroyed by reset() without saving its
accumulated data. Later the recording stop flow would find no
processor instance and silently skip the save.
Now _stop_inference() saves processor data first if recording is
still active, so data is preserved regardless of stop-button order.
partial save for crash path should not be called when stopping inference.
`shutdown()` was skipping `_cleanup_processor()` when the worker thread
stopped cleanly, leaving the custom processor's resources unreleased and its buffered data unsaved.

This commit adds the missing `_cleanup_processor()` call before tearing down the
DLCLive instance.
Stopping the DLC processor during a recording skips the processor's
`on_recording_stopped` hook, which would normally handle legacy output
copies and DB-compatible file alignment.  Show a confirmation dialog
when the user attempts to stop inference while recording is still
active, recommending they stop recording first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant