Skip to content

[Proposal] Simplify finalizing a recording #208

@oruebel

Description

@oruebel

Problem

The current recording workflow requires the users to perform the following required steps manually, which can lead to errors and makes the workflow more complicated. Specifically, during recording the user needs to:

  1. Call finalize on a select set of types (NWBFile, DynamicTable) before ending a recording to make sure the recording is being completed correctly.
  2. Make separate calls for stopRecording for the I/O and finalize for the individual containers to finalize the I/O and the Containers
  3. Ideally also clear the cache for BaseRecordingData objects for all RegisteredType objects (which is being added in Refactor how BaseRecordingData objects are managed for aquisition #190) when a recording is finished to avoid accidental reuse of invalid BaseRecordingData objects.

Goal

Ideally, a user should be able to finalize a recording via a single function call.

Proposed Approach

  1. Add a finalize method to RegisteredType and call this->clearRecordingDataCache() in the base implementation of RegisteredType.finalize to remove all the BaseRecordingData objects from the cache. This approach will:
    • Provide a standard interface, ensuring that all RegisteredType objects have a standardized finalize method (not just select types, e.g., NWBFile and DynamicTable)
    • Provides a standard process for clearing the cached BaseRecordingData objects used for recording to datasets
  2. Add BaseIO.m_recording_containers protected property (and access methods). This will:
    • Provide users with a main RecordingContainers object for tracking all containers used for recording associated with a particular IO object, so that a user doesn't need to manually create the RecordingContainers object
  3. Add RegisteredType.initialize function to add the object to the RecordingContainers object of the I/O it is associated with. This approach will:
    • Ensure that all RegistedType objects that are being used for recording are automatically added to the corresponding RecordingContainers object of the I/O backend. All RegisteredType classes already store their I/O object in this->m_io so they are already linked to the I/O and in this way would also be linked to the RecordingContainters object.
  4. Updated RecordingContainers according to Update RecordingContainer to store RegisteredType #191 . This will:
    • Allow tracking of all RegisteredType objects used for recording, not just instanced of Container
  5. Add RecordingContainers.finalize method to call finalize on all containers that it manages in RecordingContainers.m_containers. And update BaseIO.stopRecording (and HDF5IO.stopRecording) to call the new m_recording_containers.finalize() function. This will:
    • Ensure that all RegisteredType objects that are used for recording with the I/O are being finalized

This approach would enhance robustness and simplify the recording workflow by:

  • Remove the step of creating the RecordingContainers
  • Ensure that all RegisteredType object used for recording are being automatically tracked
  • Ensure that all RegisteredType objects are being finalize when the recording is being stopped, and remove the need for manually calling finalize on the the RegisteredType objects

Metadata

Metadata

Assignees

No one assigned

    Labels

    category: proposalproposed enhancements or new featurespriority: mediumnon-critical problem and/or affecting only a small set of users

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions