mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-16 08:15:19 +02:00
[core] Replace nodesDesc
with the NodePluginManager
instance
This commit is contained in:
parent
4a238b9637
commit
88bee35443
6 changed files with 19 additions and 16 deletions
|
@ -32,7 +32,6 @@ logging.basicConfig(format='[%(asctime)s][%(levelname)s] %(message)s', level=log
|
|||
sessionUid = str(uuid.uuid1())
|
||||
|
||||
cacheFolderName = 'MeshroomCache'
|
||||
nodesDesc: dict[str, desc.BaseNode] = {}
|
||||
pluginManager: NodePluginManager = NodePluginManager()
|
||||
submitters: dict[str, BaseSubmitter] = {}
|
||||
pipelineTemplates: dict[str, str] = {}
|
||||
|
@ -408,7 +407,7 @@ def loadPipelineTemplates(folder: str):
|
|||
|
||||
def initNodes():
|
||||
additionalNodesPath = EnvVar.getList(EnvVar.MESHROOM_NODES_PATH)
|
||||
nodesFolders = [os.path.join(meshroomFolder, 'nodes')] + additionalNodesPath
|
||||
nodesFolders = [os.path.join(meshroomFolder, "nodes")] + additionalNodesPath
|
||||
for f in nodesFolders:
|
||||
plugins = loadAllNodes(folder=f)
|
||||
if plugins:
|
||||
|
|
|
@ -18,7 +18,7 @@ from typing import Callable, Optional
|
|||
|
||||
import meshroom
|
||||
from meshroom.common import Signal, Variant, Property, BaseObject, Slot, ListModel, DictModel
|
||||
from meshroom.core import desc, stats, hashValue, nodeVersion, Version, MrNodeType
|
||||
from meshroom.core import desc, plugins, stats, hashValue, nodeVersion, Version, MrNodeType
|
||||
from meshroom.core.attribute import attributeFactory, ListAttribute, GroupAttribute, Attribute
|
||||
from meshroom.core.exception import NodeUpgradeError, UnknownNodeTypeError
|
||||
|
||||
|
@ -639,10 +639,12 @@ class BaseNode(BaseObject):
|
|||
super().__init__(parent)
|
||||
self._nodeType: str = nodeType
|
||||
self.nodeDesc: desc.BaseNode = None
|
||||
self.nodePlugin: plugins.Plugin = None
|
||||
|
||||
# instantiate node description if nodeType is valid
|
||||
if nodeType in meshroom.core.nodesDesc:
|
||||
self.nodeDesc = meshroom.core.nodesDesc[nodeType]()
|
||||
if meshroom.core.pluginManager.getNodePlugin(nodeType):
|
||||
self.nodeDesc = meshroom.core.pluginManager.getNodePlugin(nodeType).nodeDescriptor()
|
||||
self.nodePlugin = meshroom.core.pluginManager.getNodePlugin(nodeType)
|
||||
|
||||
self.packageName: str = ""
|
||||
self.packageVersion: str = ""
|
||||
|
|
|
@ -54,7 +54,9 @@ class _NodeCreator:
|
|||
self.internalFolder = self.nodeData.get("internalFolder")
|
||||
self.position = Position(*self.nodeData.get("position", []))
|
||||
self.uid = self.nodeData.get("uid", None)
|
||||
self.nodeDesc = meshroom.core.nodesDesc.get(self.nodeType, None)
|
||||
self.nodeDesc = None
|
||||
if meshroom.core.pluginManager.isRegistered(self.nodeType):
|
||||
self.nodeDesc = meshroom.core.pluginManager.getNodePlugin(self.nodeType).nodeDescriptor
|
||||
|
||||
def create(self) -> Union[Node, CompatibilityNode]:
|
||||
compatibilityIssue = self._checkCompatibilityIssues()
|
||||
|
|
|
@ -28,10 +28,10 @@ def checkTemplateVersions(path: str, nodesAlreadyLoaded: bool = False) -> bool:
|
|||
|
||||
for _, nodeData in graphData.items():
|
||||
nodeType = nodeData["nodeType"]
|
||||
if not nodeType in meshroom.core.nodesDesc:
|
||||
if not meshroom.core.pluginManager.isRegistered(nodeType):
|
||||
return False
|
||||
|
||||
nodeDesc = meshroom.core.nodesDesc[nodeType]
|
||||
nodeDesc = meshroom.core.pluginManager.getNodePlugin(nodeType)
|
||||
currentNodeVersion = meshroom.core.nodeVersion(nodeDesc)
|
||||
|
||||
inputs = nodeData.get("inputs", {})
|
||||
|
@ -60,9 +60,9 @@ def checkTemplateVersions(path: str, nodesAlreadyLoaded: bool = False) -> bool:
|
|||
|
||||
finally:
|
||||
if not nodesAlreadyLoaded:
|
||||
nodeTypes = [nodeType for _, nodeType in meshroom.core.nodesDesc.items()]
|
||||
for nodeType in nodeTypes:
|
||||
unregisterNodeType(nodeType)
|
||||
nodePlugins = meshroom.core.pluginManager.getNodePlugins()
|
||||
for node in nodePlugins:
|
||||
meshroom.core.pluginManager.unregisterNode(node)
|
||||
|
||||
|
||||
def checkAllTemplatesVersions() -> bool:
|
||||
|
|
|
@ -13,7 +13,7 @@ from PySide6.QtQuickControls2 import QQuickStyle
|
|||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
import meshroom
|
||||
from meshroom.core import nodesDesc
|
||||
from meshroom.core import pluginManager
|
||||
from meshroom.core.taskManager import TaskManager
|
||||
from meshroom.common import Property, Variant, Signal, Slot
|
||||
|
||||
|
@ -261,7 +261,7 @@ class MeshroomApp(QApplication):
|
|||
self.engine.addImportPath(qmlDir)
|
||||
|
||||
# expose available node types that can be instantiated
|
||||
self.engine.rootContext().setContextProperty("_nodeTypes", {n: {"category": nodesDesc[n].category} for n in sorted(nodesDesc.keys())})
|
||||
self.engine.rootContext().setContextProperty("_nodeTypes", {n: {"category": pluginManager.getNodePlugins()[n].nodeDescriptor.category} for n in sorted(pluginManager.getNodePlugins().keys())})
|
||||
|
||||
# instantiate Reconstruction object
|
||||
self._undoStack = commands.UndoStack(self)
|
||||
|
|
|
@ -537,7 +537,7 @@ class Reconstruction(UIGraph):
|
|||
# For all nodes declared to be accessed by the UI
|
||||
usedNodeTypes = {j for i in self.activeNodeCategories.values() for j in i}
|
||||
allUiNodes = set(self.uiNodes) | usedNodeTypes
|
||||
allLoadedNodeTypes = set(meshroom.core.nodesDesc.keys())
|
||||
allLoadedNodeTypes = set(meshroom.core.pluginManager.getNodePlugins().keys())
|
||||
for nodeType in allUiNodes:
|
||||
self._activeNodes.add(ActiveNode(nodeType, parent=self))
|
||||
|
||||
|
@ -684,7 +684,7 @@ class Reconstruction(UIGraph):
|
|||
if not sfmFile or not os.path.isfile(sfmFile):
|
||||
self.tempCameraInit = None
|
||||
return
|
||||
nodeDesc = meshroom.core.nodesDesc["CameraInit"]()
|
||||
nodeDesc = meshroom.core.pluginManager.getNodePlugin("CameraInit")
|
||||
views, intrinsics = nodeDesc.readSfMData(sfmFile)
|
||||
tmpCameraInit = Node("CameraInit", viewpoints=views, intrinsics=intrinsics)
|
||||
tmpCameraInit.locked = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue