[core] improve checks for sessionUid and execMode

This commit is contained in:
Fabien Castan 2025-04-13 12:48:01 +02:00
parent 299d8f29df
commit ca75e758be
2 changed files with 21 additions and 10 deletions

View file

@ -75,7 +75,7 @@ class StatusData(BaseObject):
self.packageVersion: str = packageVersion self.packageVersion: str = packageVersion
self.mrNodeType = mrNodeType self.mrNodeType = mrNodeType
self.sessionUid: Optional[str] = meshroom.core.sessionUid self.sessionUid: Optional[str] = None
self.submitterSessionUid: Optional[str] = None self.submitterSessionUid: Optional[str] = None
self.resetDynamicValues() self.resetDynamicValues()
@ -127,7 +127,9 @@ class StatusData(BaseObject):
self.startDateTime = datetime.datetime.now().strftime(self.dateTimeFormatting) self.startDateTime = datetime.datetime.now().strftime(self.dateTimeFormatting)
# to get datetime obj: datetime.datetime.strptime(obj, self.dateTimeFormatting) # to get datetime obj: datetime.datetime.strptime(obj, self.dateTimeFormatting)
self.status = Status.RUNNING 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): def initIsolatedCompute(self):
''' When submitting a node, we reset the status information to ensure that we do not keep outdated information. ''' 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 # Notify update in filepaths when node's internal folder changes
self.node.internalFolderChanged.connect(self.nodeFolderChanged) self.node.internalFolderChanged.connect(self.nodeFolderChanged)
@property @property
def index(self): def index(self):
return self.range.iteration return self.range.iteration
@ -562,8 +563,11 @@ class NodeChunk(BaseObject):
""" """
if self._status.execMode == ExecMode.EXTERN: if self._status.execMode == ExecMode.EXTERN:
return True return True
uid = self._status.submitterSessionUid if self.node.getMrNodeType() == MrNodeType.NODE else self._status.sessionUid elif self._status.execMode == ExecMode.LOCAL:
return uid != meshroom.core.sessionUid 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() statusChanged = Signal()
status = Property(Variant, lambda self: self._status, notify=statusChanged) 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 chunk has completed locally before the computations were interrupted, its execution mode will always
be local, even if computations resume externally. be local, even if computations resume externally.
""" """
if len(self._chunks) == 0:
return False
return any(chunk.isExtern() for chunk in self._chunks) return any(chunk.isExtern() for chunk in self._chunks)
@Slot() @Slot()
@ -1490,9 +1496,7 @@ class BaseNode(BaseObject):
if len(self._chunks) == 0: if len(self._chunks) == 0:
return False return False
for chunk in self._chunks: for chunk in self._chunks:
mrNodeType = chunk.node.getMrNodeType() if meshroom.core.sessionUid not in (chunk.status.sessionUid, chunk.status.submitterSessionUid):
uid = chunk.status.submitterSessionUid if mrNodeType == MrNodeType.NODE else chunk.status.sessionUid
if uid != meshroom.core.sessionUid:
return False return False
return True return True
@ -1508,6 +1512,8 @@ class BaseNode(BaseObject):
@Slot(result=bool) @Slot(result=bool)
def canBeStopped(self) -> bool: def canBeStopped(self) -> bool:
if not self.isComputable:
return False
# Only locked nodes running in local with the same # Only locked nodes running in local with the same
# sessionUid as the Meshroom instance can be stopped # sessionUid as the Meshroom instance can be stopped
return (self.getGlobalStatus() == Status.RUNNING and return (self.getGlobalStatus() == Status.RUNNING and
@ -1517,6 +1523,8 @@ class BaseNode(BaseObject):
@Slot(result=bool) @Slot(result=bool)
def canBeCanceled(self) -> bool: def canBeCanceled(self) -> bool:
if not self.isComputable:
return False
# Only locked nodes submitted in local with the same # Only locked nodes submitted in local with the same
# sessionUid as the Meshroom instance can be canceled # sessionUid as the Meshroom instance can be canceled
return (self.getGlobalStatus() == Status.SUBMITTED and return (self.getGlobalStatus() == Status.SUBMITTED and

View file

@ -593,10 +593,13 @@ class UIGraph(QObject):
def updateGraphComputingStatus(self): def updateGraphComputingStatus(self):
# update graph computing status # update graph computing status
computingLocally = any([ 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)) ch.status.status in (Status.RUNNING, Status.SUBMITTED))
for ch in self._sortedDFSChunks]) 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: if self._computingLocally != computingLocally or self._submitted != submitted:
self._computingLocally = computingLocally self._computingLocally = computingLocally
self._submitted = submitted self._submitted = submitted