mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-19 17:47:25 +02:00
[core] node: simplify with a new method isMainNode()
And add the check about duplicates for canBeStopped/canBeCanceled.
This commit is contained in:
parent
4e7de577c2
commit
8be90ce362
1 changed files with 15 additions and 3 deletions
|
@ -1339,7 +1339,7 @@ class BaseNode(BaseObject):
|
||||||
@Slot()
|
@Slot()
|
||||||
def updateDuplicatesStatusAndLocked(self):
|
def updateDuplicatesStatusAndLocked(self):
|
||||||
""" Update status of duplicate nodes without any latency and update locked. """
|
""" Update status of duplicate nodes without any latency and update locked. """
|
||||||
if self.name == self._chunks.at(0).statusNodeName:
|
if self.isMainNode():
|
||||||
for node in self._duplicates:
|
for node in self._duplicates:
|
||||||
node.updateStatusFromCache()
|
node.updateStatusFromCache()
|
||||||
|
|
||||||
|
@ -1378,7 +1378,7 @@ class BaseNode(BaseObject):
|
||||||
|
|
||||||
# Check if at least one dependentNode is submitted or currently running
|
# Check if at least one dependentNode is submitted or currently running
|
||||||
for node in outputNodes:
|
for node in outputNodes:
|
||||||
if node.getGlobalStatus() in lockedStatus and node._chunks.at(0).statusNodeName == node.name:
|
if node.getGlobalStatus() in lockedStatus and node.isMainNode():
|
||||||
stayLocked = True
|
stayLocked = True
|
||||||
break
|
break
|
||||||
if not stayLocked:
|
if not stayLocked:
|
||||||
|
@ -1387,7 +1387,7 @@ class BaseNode(BaseObject):
|
||||||
for node in inputNodes:
|
for node in inputNodes:
|
||||||
node.setLocked(False)
|
node.setLocked(False)
|
||||||
return
|
return
|
||||||
elif currentStatus in lockedStatus and self._chunks.at(0).statusNodeName == self.name:
|
elif currentStatus in lockedStatus and self.isMainNode():
|
||||||
self.setLocked(True)
|
self.setLocked(True)
|
||||||
inputNodes = self.getInputNodes(recursive=True, dependenciesOnly=True)
|
inputNodes = self.getInputNodes(recursive=True, dependenciesOnly=True)
|
||||||
for node in inputNodes:
|
for node in inputNodes:
|
||||||
|
@ -1452,12 +1452,23 @@ class BaseNode(BaseObject):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def isMainNode(self) -> bool:
|
||||||
|
""" In case of a node with duplicates, we check that the node is the one driving the computation. """
|
||||||
|
if len(self._chunks) == 0:
|
||||||
|
return True
|
||||||
|
firstChunk = self._chunks.at(0)
|
||||||
|
if not firstChunk.statusNodeName:
|
||||||
|
# If nothing is declared, anyone could become the main (if there are duplicates).
|
||||||
|
return True
|
||||||
|
return firstChunk.statusNodeName == self.name
|
||||||
|
|
||||||
@Slot(result=bool)
|
@Slot(result=bool)
|
||||||
def canBeStopped(self) -> bool:
|
def canBeStopped(self) -> bool:
|
||||||
# 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
|
||||||
self.globalExecMode == ExecMode.LOCAL.name and
|
self.globalExecMode == ExecMode.LOCAL.name and
|
||||||
|
self.isMainNode() and
|
||||||
self.initFromThisSession())
|
self.initFromThisSession())
|
||||||
|
|
||||||
@Slot(result=bool)
|
@Slot(result=bool)
|
||||||
|
@ -1466,6 +1477,7 @@ class BaseNode(BaseObject):
|
||||||
# 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
|
||||||
self.globalExecMode == ExecMode.LOCAL.name and
|
self.globalExecMode == ExecMode.LOCAL.name and
|
||||||
|
self.isMainNode() and
|
||||||
self.initFromThisSession())
|
self.initFromThisSession())
|
||||||
|
|
||||||
def hasImageOutputAttribute(self) -> bool:
|
def hasImageOutputAttribute(self) -> bool:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue