Skip to content

Commit

Permalink
auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Hog committed Oct 8, 2024
1 parent f982c1a commit 24c4585
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
6 changes: 5 additions & 1 deletion meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check notice on line 1424 in meshroom/core/node.py

View check run for this annotation

codefactor.io / CodeFactor

meshroom/core/node.py#L1424

Multiple spaces after ','. (E241)

Check notice on line 1424 in meshroom/core/node.py

View check run for this annotation

codefactor.io / CodeFactor

meshroom/core/node.py#L1424

Multiple spaces before operator. (E221)
# isBuiltStatus = Property(bool, lambda self: self.nodeDesc.isBuilt, constant=True)

class Node(BaseNode):
"""
Expand Down
28 changes: 25 additions & 3 deletions meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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()

Expand All @@ -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:
Expand All @@ -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):
Expand All @@ -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. """
Expand All @@ -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.
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion meshroom/ui/qml/GraphEditor/Node.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion meshroom/ui/qml/GraphEditor/NodeEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 24c4585

Please sign in to comment.