[core][graphIO] Improve node type version handling

* Deserialization: Replace the logic that defaulted the node type version to "0.0" when unspecified,
and assume that unspecified version on a node is targetting current node type version.
* Serialization: Only serialize node type versions for which a version info is available.

* Test suites:
  * Add helper context manager to manually override the version of a given node type.
  * Add new unit tests to cover version conflicts handling is various scenarios.
This commit is contained in:
Yann Lanthony 2025-02-06 16:46:05 +01:00
parent d9e59e330a
commit 87fbcee06d
7 changed files with 98 additions and 9 deletions

View file

@ -100,7 +100,9 @@ class GraphSerializer:
"""Get registered versions of each node types in `nodes`, excluding CompatibilityNode instances."""
nodeTypes = set([node.nodeDesc.__class__ for node in self.nodes if isinstance(node, Node)])
nodeTypesVersions = {
nodeType.__name__: meshroom.core.nodeVersion(nodeType, "0.0") for nodeType in nodeTypes
nodeType.__name__: version
for nodeType in nodeTypes
if (version := meshroom.core.nodeVersion(nodeType)) is not None
}
# Sort them by name (to avoid random order changing from one save to another).
return dict(sorted(nodeTypesVersions.items()))