Skip to content

Object references in titles are not remapped when appending an HDF5 workspace #357

Description

@StefanoPierini-Codra

Object references in titles are not remapped when appending an HDF5 workspace

Summary

When an HDF5 workspace is loaded in append mode (i.e. into a session that already contains objects), the objects and groups read from the file are renumbered, but the short IDs embedded in their titles are not. Every generated title that references another object (fft(s001), average(gs001), µ(s001, s002), ...) therefore points to the wrong object, or to an object that belongs to a completely different workflow.

Steps to reproduce

  1. Start DataLab with an empty signal panel.
  2. Create two signals (they get s001, s002), rename their group to Imported sources (gs001).
  3. Compute average on the group → new group gs002 titled average(gs001) containing s004 titled µ(s001, s002).
  4. Compute fft on the first signal → s003 titled fft(s001).
  5. Save the workspace to probe.h5.
  6. Clear all panels, create one new signal (so the session is not empty).
  7. Load probe.h5 with append (reset_all=False).

Actual result

BEFORE SAVE                          AFTER APPEND
gs001: 'Imported sources'            gs001: ''                    <- pre-existing object
    s001: cosine(...)                    s001: cosine(...)
    s002: cosine(...)                gs002: 'Imported sources'
    s003: 'fft(s001)'                    s002: cosine(...)
gs002: 'average(gs001)'                  s003: cosine(...)
    s004: 'µ(s001, s002)'                s004: 'fft(s001)'        <- should be fft(s002)
                                     gs003: 'average(gs001)'      <- should be average(gs002)
                                         s005: 'µ(s001, s002)'    <- should be µ(s002, s003)

Because s001 and gs001 now designate the pre-existing objects of the session, the titles silently describe a wrong lineage.

Expected result

All short IDs contained in the titles of imported items should be rewritten to the short IDs those items receive in the current session:

gs002: 'Imported sources'
    s002 / s003: cosine(...)
    s004: 'fft(s002)'
gs003: 'average(gs002)'
    s005: 'µ(s002, s003)'

Root cause

ObjectModel.add_object() performs the usual short-ID ↔ UUID swap using the current model mapping. But the titles read from the file carry the file's short IDs, which have no relation to the current numbering. In addition, group UUIDs stored in the file are lost: deserialize_from_hdf5() calls add_group(), which allocates a fresh UUID, so group references cannot be resolved either.

Relevant code:

  • datalab/gui/panel/base.pyBaseDataPanel.deserialize_from_hdf5()
  • datalab/objectmodel.pyObjectModel.add_object(), replace_short_ids_by_uuids_in_titles(), replace_uuids_by_short_ids_in_titles()

Notes

A regression test exists on the feature/149-replace-object-short-names-by-their-title branch: datalab/tests/features/common/computed_title_regressions_app_test.py::test_h5_append_remaps_group_computed_title.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions