Skip to content

Centralize data migrations definitions and handling #1222

Description

@yarikoptic

Is your feature request related to a problem? Please describe.

NWB is still evolving, quite frequently requiring data migrations. ATM migrations are coded in various places/data types, often with code duplication to handle them (see e.g. #1219). For a user there is no way to discover what really would change in his existing file if he would to migrate to a new version of NWB.
validate ATM would use schema stored along with the file, without alerting user (with some kind of INFO or WARNING) that some values are to be changed in a new version of NWB (#1216 - based on #1219 use case)

Describe the solution you'd like

Provide a registry and support tooling for data migrations, so that

  • make migrations described more "declaratively" than "functionally" (coded up)
  • apply them centrally
  • there could be an easy way to get them all given a specific NWB version of the file, to see which are relevant and to be done
  • to minimize code duplication and simplify testing

e.g. for #1219 I could see properties like (if to be described as yaml)

codename: hardcoded_units_210
description: Since NWB 2.1.0 units for those neural data types must not be specified, and will be hardcoded
nwb_versions: "< 2.1.0"  # some way to describe where applicable? but might be just an additional filter
callable: ensure_unit
stage: init  # describing when should be fixed up?  need more use cases to see what needed
objects:  # provide filters and arguments so support code could decide where to apply
 - ndtype: CurrentClampSeries
   unit: volts
 - ndtype: CurrentClampStimulusSeries
   unit: amperes
 ...

Then underlying __init__ of the base class (or might be even __new__ before) would just see if there is a match for a given data migration given the class at hands and properties (versions and values may be) and apply migration. Might need more thought, but first I wanted to suggest the principle, and you would probably know of other cases where similar migrations are happening so we could lay them out first to generalize the spec flexible enough to allow their specification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions