Merge pull request #1832 from alicevision/fix/graphLocalComputations

[ui] Correctly determine if a graph is being computed locally and update nodes' statuses accordingly
This commit is contained in:
Fabien Castan 2022-12-05 16:20:58 +01:00 committed by GitHub
commit 8ce2ac6fe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View file

@ -1366,6 +1366,11 @@ class Graph(BaseObject):
for node in self.nodes:
node.clearSubmittedChunks()
def clearLocallySubmittedNodes(self):
""" Reset the status of already locally submitted nodes to Status.NONE """
for node in self.nodes:
node.clearLocallySubmittedChunks()
def iterChunksByStatus(self, status):
""" Iterate over NodeChunks with the given status """
for node in self.nodes:

View file

@ -433,7 +433,8 @@ class NodeChunk(BaseObject):
self.node.nodeDesc.stopProcess(self)
def isExtern(self):
return self._status.execMode == ExecMode.EXTERN
return self._status.execMode == ExecMode.EXTERN or (
self._status.execMode == ExecMode.LOCAL and self._status.sessionUid != meshroom.core.sessionUid)
statusChanged = Signal()
status = Property(Variant, lambda self: self._status, notify=statusChanged)
@ -779,6 +780,12 @@ class BaseNode(BaseObject):
if chunk.isAlreadySubmitted():
chunk.upgradeStatusTo(Status.NONE, ExecMode.NONE)
def clearLocallySubmittedChunks(self):
""" Reset all locally submitted chunks to Status.NONE. """
for chunk in self._chunks:
if chunk.isAlreadySubmitted() and not chunk.isExtern():
chunk.upgradeStatusTo(Status.NONE, ExecMode.NONE)
def upgradeStatusTo(self, newStatus):
"""
Upgrade node to the given status and save it on disk.

View file

@ -11,6 +11,7 @@ from multiprocessing.pool import ThreadPool
from PySide2.QtCore import Slot, QJsonValue, QObject, QUrl, Property, Signal, QPoint
from meshroom import multiview
from meshroom.core import sessionUid
from meshroom.common.qt import QObjectListModel
from meshroom.core.attribute import Attribute, ListAttribute
from meshroom.core.graph import Graph, Edge
@ -283,6 +284,9 @@ class UIGraph(QObject):
""" Set the internal graph. """
if self._graph:
self.stopExecution()
# Clear all the locally submitted nodes at once before the graph gets changed, as it won't receive further updates
if self._computingLocally:
self._graph.clearLocallySubmittedNodes()
self.clear()
oldGraph = self._graph
self._graph = g
@ -457,7 +461,11 @@ class UIGraph(QObject):
def updateGraphComputingStatus(self):
# update graph computing status
computingLocally = any([ch.status.execMode == ExecMode.LOCAL and ch.status.status in (Status.RUNNING, Status.SUBMITTED) for ch in self._sortedDFSChunks])
computingLocally = any([
(ch.status.execMode == ExecMode.LOCAL and
ch.status.sessionUid == sessionUid and
ch.status.status in (Status.RUNNING, Status.SUBMITTED))
for ch in self._sortedDFSChunks])
submitted = any([ch.status.status == Status.SUBMITTED for ch in self._sortedDFSChunks])
if self._computingLocally != computingLocally or self._submitted != submitted:
self._computingLocally = computingLocally