Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Correctly determine if a graph is being computed locally and update nodes' statuses accordingly #1832

Merged
merged 3 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions meshroom/core/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,11 @@ def clearSubmittedNodes(self):
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:
Expand Down
9 changes: 8 additions & 1 deletion meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ def stopProcess(self):
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)
Expand Down Expand Up @@ -779,6 +780,12 @@ def clearSubmittedChunks(self):
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.
Expand Down
10 changes: 9 additions & 1 deletion meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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
Expand Down Expand Up @@ -283,6 +284,9 @@ def setGraph(self, g):
""" 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
Expand Down Expand Up @@ -454,7 +458,11 @@ def submit(self, node=None):

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
Expand Down