devctrl.data.upgrade#
Unified data-format upgrade machinery.
Every hdf5 measurement file carries the root attributes data_type and data_version
(see devctrl.data.hdf5). This module provides the shared machinery to upgrade data
from an old format version to a newer one:
Upgrade chains are declared per
data_typeas a registry ofUpgradeStepobjects (register_upgradedecorator,upgrade_chain()resolves a path through the registry).A
DataFormatAdapterperdata_typedefines how the data is loaded, saved and how its format version is detected when the file does not carry adata_versionattribute (legacy data).upgrade_data()runs a chain on a file or measurement directory, either in place with a backup (strategy="backup", the original is kept as<name>-original, for files before the extension) or into a fresh directory (strategy="new-dir", like the prsctrl conversion script).
Modules register their adapters and upgrade steps at import time, so importing a module’s
data package is enough to make its formats upgradable. The version comparison is
numeric-aware: "0.9" < "0.10" < "0.12" < "1.0".
Functions
Add an upgrade step to the registry. |
|
Compare two |
|
Detect the canonical data type and format version of the data at |
|
Get the registered data format adapter for a canonical data type. |
|
Whether the data at |
|
Register a data format adapter. |
|
Decorator registering the decorated function as an upgrade step. |
|
All canonical data types with a registered adapter, in registration order. |
|
Resolve the chain of upgrade steps from one format version to another. |
|
Upgrade the data at |
Classes
Per- |
|
A single conversion step between two format versions of one data type. |