mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-14 15:27:21 +02:00
[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:
parent
d9e59e330a
commit
87fbcee06d
7 changed files with 98 additions and 9 deletions
|
@ -1,7 +1,9 @@
|
|||
from contextlib import contextmanager
|
||||
from unittest.mock import patch
|
||||
from typing import Type
|
||||
from meshroom.core import registerNodeType, unregisterNodeType
|
||||
|
||||
import meshroom
|
||||
from meshroom.core import registerNodeType, unregisterNodeType
|
||||
from meshroom.core import desc
|
||||
|
||||
@contextmanager
|
||||
|
@ -13,3 +15,14 @@ def registeredNodeTypes(nodeTypes: list[Type[desc.Node]]):
|
|||
|
||||
for nodeType in nodeTypes:
|
||||
unregisterNodeType(nodeType)
|
||||
|
||||
@contextmanager
|
||||
def overrideNodeTypeVersion(nodeType: Type[desc.Node], version: str):
|
||||
"""Helper context manager to override the version of a given node type."""
|
||||
unpatchedFunc = meshroom.core.nodeVersion
|
||||
with patch.object(
|
||||
meshroom.core,
|
||||
"nodeVersion",
|
||||
side_effect=lambda type: version if type is nodeType else unpatchedFunc(type),
|
||||
):
|
||||
yield
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue