From 24c4585878bf6682a022f8db5a3baee77d22bdf5 Mon Sep 17 00:00:00 2001 From: Matthieu Hog Date: Mon, 7 Oct 2024 17:04:24 +0200 Subject: [PATCH] auto update --- meshroom/core/node.py | 6 ++++- meshroom/ui/graph.py | 28 +++++++++++++++++++--- meshroom/ui/qml/GraphEditor/Node.qml | 2 +- meshroom/ui/qml/GraphEditor/NodeEditor.qml | 2 +- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/meshroom/core/node.py b/meshroom/core/node.py index aeb3903727..2e3c9cfa82 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -1418,7 +1418,11 @@ def has3DOutputAttribute(self): has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged) isPlugin = Property(bool, lambda self: self.nodeDesc.isPlugin, constant=True) - isBuilt = Property(bool, lambda self: self.nodeDesc.isBuilt, constant=True) + + isEnvBuild = (not isPlugin) #init build status false its not a plugin + buildStatusChanged = Signal() #event to notify change in status + isBuiltStatus = Property(bool, lambda self: self.isEnvBuild, notify = buildStatusChanged) + # isBuiltStatus = Property(bool, lambda self: self.nodeDesc.isBuilt, constant=True) class Node(BaseNode): """ diff --git a/meshroom/ui/graph.py b/meshroom/ui/graph.py index 448f25484a..0c3fa816fa 100644 --- a/meshroom/ui/graph.py +++ b/meshroom/ui/graph.py @@ -44,6 +44,7 @@ def __init__(self, parent=None): self._stopFlag = Event() self._refreshInterval = 5 # refresh interval in seconds self._files = [] + self._nodes = [] if submitters: self._filePollerRefresh = PollerRefreshStatus.MINIMAL_ENABLED else: @@ -53,7 +54,7 @@ def __del__(self): self._threadPool.terminate() self._threadPool.join() - def start(self, files=None): + def start(self, files=None, nodes=None): """ Start polling thread. Args: @@ -66,6 +67,7 @@ def start(self, files=None): return self._stopFlag.clear() self._files = files or [] + self._nodes = nodes or [] self._thread = Thread(target=self.run) self._thread.start() @@ -78,6 +80,15 @@ def setFiles(self, files): with self._mutex: self._files = files + def setNodes(self, nodes): + """ Set the list of nodes to monitor + + Args: + nodes: the list of nodes to monitor + """ + with self._mutex: + self._nodes = nodes + def stop(self): """ Request polling thread to stop. """ if not self._thread: @@ -94,6 +105,13 @@ def getFileLastModTime(f): except OSError: return -1 + @staticmethod + def updatePluginEnvStatus(n): + """ Will update the status of the plugin env """ + print("Refreshing "+str(n)) + n.isEnvBuild=n.nodeDesc.isBuilt + n.buildStatusChanged.emit() + def run(self): """ Poll watched files for last modification time. """ while not self._stopFlag.wait(self._refreshInterval): @@ -103,6 +121,8 @@ def run(self): with self._mutex: if files == self._files: self.timesAvailable.emit(times) + #update plugin nodes + _ = self._threadPool.map(self.updatePluginEnvStatus, self._nodes) def onFilePollerRefreshChanged(self, value): """ Stop or start the file poller depending on the new refresh status. """ @@ -116,7 +136,6 @@ def onFilePollerRefreshChanged(self, value): filePollerRefresh = Property(int, lambda self: self._filePollerRefresh.value, constant=True) filePollerRefreshReady = Signal() # The refresh status has been updated and is ready to be used - class ChunksMonitor(QObject): """ ChunksMonitor regularly check NodeChunks' status files for modification and trigger their update on change. @@ -147,6 +166,8 @@ def setChunks(self, chunks): self.monitorableChunks = chunks files, monitoredChunks = self.watchedStatusFiles self._filesTimePoller.setFiles(files) + pluginNodes = [c.node for c in chunks if c.node.isPlugin] + self._filesTimePoller.setNodes(pluginNodes) self.monitoredChunks = monitoredChunks def stop(self): @@ -172,7 +193,8 @@ def watchedStatusFiles(self): elif self.filePollerRefresh is PollerRefreshStatus.MINIMAL_ENABLED.value: for c in self.monitorableChunks: # When a chunk's status is ERROR, it may be externally re-submitted and it should thus still be monitored - if c._status.status is Status.SUBMITTED or c._status.status is Status.RUNNING or c._status.status is Status.ERROR: + #Plugin nodes are always moniotored + if c.node.isPlugin or c._status.status is Status.SUBMITTED or c._status.status is Status.RUNNING or c._status.status is Status.ERROR: files.append(c.statusFile) chunks.append(c) return files, chunks diff --git a/meshroom/ui/qml/GraphEditor/Node.qml b/meshroom/ui/qml/GraphEditor/Node.qml index 6c1eb385c9..34707b9ed7 100755 --- a/meshroom/ui/qml/GraphEditor/Node.qml +++ b/meshroom/ui/qml/GraphEditor/Node.qml @@ -21,7 +21,7 @@ Item { readonly property bool isCompatibilityNode: node ? node.hasOwnProperty("compatibilityIssue") : false /// Whether the node is a plugin that needs to be build readonly property bool isPlugin: node ? node.isPlugin : false - property bool isNotBuilt: node ? (!node.isBuilt) : false + property bool isNotBuilt: node ? (!node.isBuiltStatus) : false /// Mouse related states property bool mainSelected: false property bool selected: false diff --git a/meshroom/ui/qml/GraphEditor/NodeEditor.qml b/meshroom/ui/qml/GraphEditor/NodeEditor.qml index 84daec1ddf..a16f92e9fa 100644 --- a/meshroom/ui/qml/GraphEditor/NodeEditor.qml +++ b/meshroom/ui/qml/GraphEditor/NodeEditor.qml @@ -19,7 +19,7 @@ Panel { property bool isCompatibilityNode: node && node.compatibilityIssue !== undefined property string nodeStartDateTime: "" readonly property bool isPlugin: node ? node.isPlugin : false - readonly property bool isNotBuilt: node ? (!node.isBuilt) : false + property bool isNotBuilt: node ? (!node.isBuiltStatus) : false signal attributeDoubleClicked(var mouse, var attribute) signal upgradeRequest()