From ca75e758be82eb25f76123f8f1dc37595a1cda5b Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Sun, 13 Apr 2025 12:48:01 +0200 Subject: [PATCH] [core] improve checks for sessionUid and execMode --- meshroom/core/node.py | 24 ++++++++++++++++-------- meshroom/ui/graph.py | 7 +++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/meshroom/core/node.py b/meshroom/core/node.py index 41492bda..1ee3fce3 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -75,7 +75,7 @@ class StatusData(BaseObject): self.packageVersion: str = packageVersion self.mrNodeType = mrNodeType - self.sessionUid: Optional[str] = meshroom.core.sessionUid + self.sessionUid: Optional[str] = None self.submitterSessionUid: Optional[str] = None self.resetDynamicValues() @@ -127,7 +127,9 @@ class StatusData(BaseObject): self.startDateTime = datetime.datetime.now().strftime(self.dateTimeFormatting) # to get datetime obj: datetime.datetime.strptime(obj, self.dateTimeFormatting) self.status = Status.RUNNING - self.execMode = ExecMode.LOCAL + # Note: We do not modify the "execMode" here, as it is set in the init*Submit methods. + # When we compute (from renderfarm or isolated environment), + # we don't want to modify the execMode set from the submit. def initIsolatedCompute(self): ''' When submitting a node, we reset the status information to ensure that we do not keep outdated information. @@ -319,7 +321,6 @@ class NodeChunk(BaseObject): # Notify update in filepaths when node's internal folder changes self.node.internalFolderChanged.connect(self.nodeFolderChanged) - @property def index(self): return self.range.iteration @@ -562,8 +563,11 @@ class NodeChunk(BaseObject): """ if self._status.execMode == ExecMode.EXTERN: return True - uid = self._status.submitterSessionUid if self.node.getMrNodeType() == MrNodeType.NODE else self._status.sessionUid - return uid != meshroom.core.sessionUid + elif self._status.execMode == ExecMode.LOCAL: + if self._status.status in (Status.SUBMITTED, Status.RUNNING): + return meshroom.core.sessionUid not in (self._status.submitterSessionUid, self._status.sessionUid) + return False + return False statusChanged = Signal() status = Property(Variant, lambda self: self._status, notify=statusChanged) @@ -1033,6 +1037,8 @@ class BaseNode(BaseObject): chunk has completed locally before the computations were interrupted, its execution mode will always be local, even if computations resume externally. """ + if len(self._chunks) == 0: + return False return any(chunk.isExtern() for chunk in self._chunks) @Slot() @@ -1490,9 +1496,7 @@ class BaseNode(BaseObject): if len(self._chunks) == 0: return False for chunk in self._chunks: - mrNodeType = chunk.node.getMrNodeType() - uid = chunk.status.submitterSessionUid if mrNodeType == MrNodeType.NODE else chunk.status.sessionUid - if uid != meshroom.core.sessionUid: + if meshroom.core.sessionUid not in (chunk.status.sessionUid, chunk.status.submitterSessionUid): return False return True @@ -1508,6 +1512,8 @@ class BaseNode(BaseObject): @Slot(result=bool) def canBeStopped(self) -> bool: + if not self.isComputable: + return False # Only locked nodes running in local with the same # sessionUid as the Meshroom instance can be stopped return (self.getGlobalStatus() == Status.RUNNING and @@ -1517,6 +1523,8 @@ class BaseNode(BaseObject): @Slot(result=bool) def canBeCanceled(self) -> bool: + if not self.isComputable: + return False # Only locked nodes submitted in local with the same # sessionUid as the Meshroom instance can be canceled return (self.getGlobalStatus() == Status.SUBMITTED and diff --git a/meshroom/ui/graph.py b/meshroom/ui/graph.py index d5062bf8..f2826506 100644 --- a/meshroom/ui/graph.py +++ b/meshroom/ui/graph.py @@ -593,10 +593,13 @@ class UIGraph(QObject): def updateGraphComputingStatus(self): # update graph computing status computingLocally = any([ - ((ch.status.submitterSessionUid if ch.node.getMrNodeType() == MrNodeType.NODE else ch.status.sessionUid) == sessionUid) and ( + ch.status.execMode == ExecMode.LOCAL and + (sessionUid in (ch.status.submitterSessionUid, ch.status.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]) + # Note: We do not check sessionUid for the submitted status, + # as the source instance of the submit has no importance. + submitted = any([ch.status.execMode == ExecMode.EXTERN and ch.status.status in (Status.RUNNING, Status.SUBMITTED) for ch in self._sortedDFSChunks]) if self._computingLocally != computingLocally or self._submitted != submitted: self._computingLocally = computingLocally self._submitted = submitted