mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-13 14:57:22 +02:00
[core] plugins: Rename getNodePlugin...
to getRegisteredNodePlugin...
This prevents ambiguities between `NodePlugin` objects that have been registered (and are thus instantiable) and those that belong to `Plugin` objects but have not been registered.
This commit is contained in:
parent
c16b56c7e3
commit
98d90dae81
7 changed files with 17 additions and 17 deletions
|
@ -642,9 +642,9 @@ class BaseNode(BaseObject):
|
||||||
self.nodePlugin: plugins.Plugin = None
|
self.nodePlugin: plugins.Plugin = None
|
||||||
|
|
||||||
# instantiate node description if nodeType is valid
|
# instantiate node description if nodeType is valid
|
||||||
if meshroom.core.pluginManager.getNodePlugin(nodeType):
|
if meshroom.core.pluginManager.getRegisteredNodePlugin(nodeType):
|
||||||
self.nodeDesc = meshroom.core.pluginManager.getNodePlugin(nodeType).nodeDescriptor()
|
self.nodeDesc = meshroom.core.pluginManager.getRegisteredNodePlugin(nodeType).nodeDescriptor()
|
||||||
self.nodePlugin = meshroom.core.pluginManager.getNodePlugin(nodeType)
|
self.nodePlugin = meshroom.core.pluginManager.getRegisteredNodePlugin(nodeType)
|
||||||
|
|
||||||
self.packageName: str = ""
|
self.packageName: str = ""
|
||||||
self.packageVersion: str = ""
|
self.packageVersion: str = ""
|
||||||
|
|
|
@ -56,7 +56,7 @@ class _NodeCreator:
|
||||||
self.uid = self.nodeData.get("uid", None)
|
self.uid = self.nodeData.get("uid", None)
|
||||||
self.nodeDesc = None
|
self.nodeDesc = None
|
||||||
if meshroom.core.pluginManager.isRegistered(self.nodeType):
|
if meshroom.core.pluginManager.isRegistered(self.nodeType):
|
||||||
self.nodeDesc = meshroom.core.pluginManager.getNodePlugin(self.nodeType).nodeDescriptor
|
self.nodeDesc = meshroom.core.pluginManager.getRegisteredNodePlugin(self.nodeType).nodeDescriptor
|
||||||
|
|
||||||
def create(self) -> Union[Node, CompatibilityNode]:
|
def create(self) -> Union[Node, CompatibilityNode]:
|
||||||
compatibilityIssue = self._checkCompatibilityIssues()
|
compatibilityIssue = self._checkCompatibilityIssues()
|
||||||
|
|
|
@ -262,14 +262,14 @@ class NodePluginManager(BaseObject):
|
||||||
if not self.getPlugin(plugin.name):
|
if not self.getPlugin(plugin.name):
|
||||||
self._plugins[plugin.name] = plugin
|
self._plugins[plugin.name] = plugin
|
||||||
|
|
||||||
def getNodePlugins(self) -> dict[str: NodePlugin]:
|
def getRegisteredNodePlugins(self) -> dict[str: NodePlugin]:
|
||||||
"""
|
"""
|
||||||
Return a dictionary containing all the registered NodePlugins, with
|
Return a dictionary containing all the registered NodePlugins, with
|
||||||
{key, value} = {name, NodePlugin}.
|
{key, value} = {name, NodePlugin}.
|
||||||
"""
|
"""
|
||||||
return self._nodePlugins
|
return self._nodePlugins
|
||||||
|
|
||||||
def getNodePlugin(self, name: str) -> NodePlugin:
|
def getRegisteredNodePlugin(self, name: str) -> NodePlugin:
|
||||||
"""
|
"""
|
||||||
Return the NodePlugin object that has been registered under the name "name" if it exists.
|
Return the NodePlugin object that has been registered under the name "name" if it exists.
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ def checkTemplateVersions(path: str, nodesAlreadyLoaded: bool = False) -> bool:
|
||||||
if not meshroom.core.pluginManager.isRegistered(nodeType):
|
if not meshroom.core.pluginManager.isRegistered(nodeType):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
nodeDesc = meshroom.core.pluginManager.getNodePlugin(nodeType)
|
nodeDesc = meshroom.core.pluginManager.getRegisteredNodePlugin(nodeType)
|
||||||
currentNodeVersion = meshroom.core.nodeVersion(nodeDesc)
|
currentNodeVersion = meshroom.core.nodeVersion(nodeDesc)
|
||||||
|
|
||||||
inputs = nodeData.get("inputs", {})
|
inputs = nodeData.get("inputs", {})
|
||||||
|
@ -60,7 +60,7 @@ def checkTemplateVersions(path: str, nodesAlreadyLoaded: bool = False) -> bool:
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if not nodesAlreadyLoaded:
|
if not nodesAlreadyLoaded:
|
||||||
nodePlugins = meshroom.core.pluginManager.getNodePlugins()
|
nodePlugins = meshroom.core.pluginManager.getRegisteredNodePlugins()
|
||||||
for node in nodePlugins:
|
for node in nodePlugins:
|
||||||
meshroom.core.pluginManager.unregisterNode(node)
|
meshroom.core.pluginManager.unregisterNode(node)
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ class MeshroomApp(QApplication):
|
||||||
self.engine.addImportPath(qmlDir)
|
self.engine.addImportPath(qmlDir)
|
||||||
|
|
||||||
# expose available node types that can be instantiated
|
# expose available node types that can be instantiated
|
||||||
self.engine.rootContext().setContextProperty("_nodeTypes", {n: {"category": pluginManager.getNodePlugins()[n].nodeDescriptor.category} for n in sorted(pluginManager.getNodePlugins().keys())})
|
self.engine.rootContext().setContextProperty("_nodeTypes", {n: {"category": pluginManager.getRegisteredNodePlugins()[n].nodeDescriptor.category} for n in sorted(pluginManager.getRegisteredNodePlugins().keys())})
|
||||||
|
|
||||||
# instantiate Reconstruction object
|
# instantiate Reconstruction object
|
||||||
self._undoStack = commands.UndoStack(self)
|
self._undoStack = commands.UndoStack(self)
|
||||||
|
|
|
@ -537,7 +537,7 @@ class Reconstruction(UIGraph):
|
||||||
# For all nodes declared to be accessed by the UI
|
# For all nodes declared to be accessed by the UI
|
||||||
usedNodeTypes = {j for i in self.activeNodeCategories.values() for j in i}
|
usedNodeTypes = {j for i in self.activeNodeCategories.values() for j in i}
|
||||||
allUiNodes = set(self.uiNodes) | usedNodeTypes
|
allUiNodes = set(self.uiNodes) | usedNodeTypes
|
||||||
allLoadedNodeTypes = set(meshroom.core.pluginManager.getNodePlugins().keys())
|
allLoadedNodeTypes = set(meshroom.core.pluginManager.getRegisteredNodePlugins().keys())
|
||||||
for nodeType in allUiNodes:
|
for nodeType in allUiNodes:
|
||||||
self._activeNodes.add(ActiveNode(nodeType, parent=self))
|
self._activeNodes.add(ActiveNode(nodeType, parent=self))
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ class Reconstruction(UIGraph):
|
||||||
if not sfmFile or not os.path.isfile(sfmFile):
|
if not sfmFile or not os.path.isfile(sfmFile):
|
||||||
self.tempCameraInit = None
|
self.tempCameraInit = None
|
||||||
return
|
return
|
||||||
nodeDesc = meshroom.core.pluginManager.getNodePlugin("CameraInit")
|
nodeDesc = meshroom.core.pluginManager.getRegisteredNodePlugin("CameraInit")
|
||||||
views, intrinsics = nodeDesc.readSfMData(sfmFile)
|
views, intrinsics = nodeDesc.readSfMData(sfmFile)
|
||||||
tmpCameraInit = Node("CameraInit", viewpoints=views, intrinsics=intrinsics)
|
tmpCameraInit = Node("CameraInit", viewpoints=views, intrinsics=intrinsics)
|
||||||
tmpCameraInit.locked = True
|
tmpCameraInit.locked = True
|
||||||
|
|
|
@ -170,7 +170,7 @@ class SampleInputNodeV2(desc.InputNode):
|
||||||
|
|
||||||
def replaceNodeTypeDesc(nodeType: str, nodeDesc: Type[desc.Node]):
|
def replaceNodeTypeDesc(nodeType: str, nodeDesc: Type[desc.Node]):
|
||||||
"""Change the `nodeDesc` associated to `nodeType`."""
|
"""Change the `nodeDesc` associated to `nodeType`."""
|
||||||
pluginManager.getNodePlugins()[nodeType] = NodePlugin(nodeDesc)
|
pluginManager.getRegisteredNodePlugins()[nodeType] = NodePlugin(nodeDesc)
|
||||||
|
|
||||||
|
|
||||||
def test_unknown_node_type():
|
def test_unknown_node_type():
|
||||||
|
@ -216,7 +216,7 @@ def test_description_conflict():
|
||||||
Test compatibility behavior for conflicting node descriptions.
|
Test compatibility behavior for conflicting node descriptions.
|
||||||
"""
|
"""
|
||||||
# Copy registered node types to be able to restore them
|
# Copy registered node types to be able to restore them
|
||||||
originalNodeTypes = copy.deepcopy(pluginManager.getNodePlugins())
|
originalNodeTypes = copy.deepcopy(pluginManager.getRegisteredNodePlugins())
|
||||||
|
|
||||||
nodeTypes = [SampleNodeV1, SampleNodeV2, SampleNodeV3, SampleNodeV4, SampleNodeV5]
|
nodeTypes = [SampleNodeV1, SampleNodeV2, SampleNodeV3, SampleNodeV4, SampleNodeV5]
|
||||||
nodes = []
|
nodes = []
|
||||||
|
@ -242,7 +242,7 @@ def test_description_conflict():
|
||||||
# Offset node types register to create description conflicts
|
# Offset node types register to create description conflicts
|
||||||
# Each node type name now reference the next one's implementation
|
# Each node type name now reference the next one's implementation
|
||||||
for i, nt in enumerate(nodeTypes[:-1]):
|
for i, nt in enumerate(nodeTypes[:-1]):
|
||||||
pluginManager.getNodePlugins()[nt.__name__] = NodePlugin(nodeTypes[i + 1])
|
pluginManager.getRegisteredNodePlugins()[nt.__name__] = NodePlugin(nodeTypes[i + 1])
|
||||||
|
|
||||||
# Reload file
|
# Reload file
|
||||||
g = loadGraph(graphFile)
|
g = loadGraph(graphFile)
|
||||||
|
@ -359,8 +359,8 @@ def test_upgradeAllNodes():
|
||||||
pluginManager.unregisterNode(nodePluginSampleInputV2)
|
pluginManager.unregisterNode(nodePluginSampleInputV2)
|
||||||
|
|
||||||
# Replace SampleNodeV1 by SampleNodeV2 and SampleInputNodeV1 by SampleInputNodeV2
|
# Replace SampleNodeV1 by SampleNodeV2 and SampleInputNodeV1 by SampleInputNodeV2
|
||||||
pluginManager.getNodePlugins()[nodePluginSampleV1.nodeDescriptor.__name__] = nodePluginSampleV2
|
pluginManager.getRegisteredNodePlugins()[nodePluginSampleV1.nodeDescriptor.__name__] = nodePluginSampleV2
|
||||||
pluginManager.getNodePlugins()[nodePluginSampleInputV1.nodeDescriptor.__name__] = \
|
pluginManager.getRegisteredNodePlugins()[nodePluginSampleInputV1.nodeDescriptor.__name__] = \
|
||||||
nodePluginSampleInputV2
|
nodePluginSampleInputV2
|
||||||
|
|
||||||
# Reload file
|
# Reload file
|
||||||
|
@ -400,7 +400,7 @@ def test_conformUpgrade():
|
||||||
g.save(graphFile)
|
g.save(graphFile)
|
||||||
|
|
||||||
# Replace SampleNodeV5 by SampleNodeV6
|
# Replace SampleNodeV5 by SampleNodeV6
|
||||||
pluginManager.getNodePlugins()[nodePluginSampleV5.nodeDescriptor.__name__] = nodePluginSampleV6
|
pluginManager.getRegisteredNodePlugins()[nodePluginSampleV5.nodeDescriptor.__name__] = nodePluginSampleV6
|
||||||
|
|
||||||
# Reload file
|
# Reload file
|
||||||
g = loadGraph(graphFile)
|
g = loadGraph(graphFile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue