mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-22 21:46:28 +02:00
[core] reset status of submitted nodes when a node computation fails
* catch Exception and stop graph execution * report error using logging.error * misc: fix indentation issues
This commit is contained in:
parent
fd0c209837
commit
e49fdf457c
1 changed files with 20 additions and 7 deletions
|
@ -11,6 +11,7 @@ import uuid
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from enum import Enum # available by default in python3. For python2: "pip install enum34"
|
from enum import Enum # available by default in python3. For python2: "pip install enum34"
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
import logging
|
||||||
|
|
||||||
from . import stats
|
from . import stats
|
||||||
from meshroom import core as pg
|
from meshroom import core as pg
|
||||||
|
@ -445,19 +446,18 @@ class Node(BaseObject):
|
||||||
self.status.returnCode = self._subprocess.returncode
|
self.status.returnCode = self._subprocess.returncode
|
||||||
|
|
||||||
if self._subprocess.returncode != 0:
|
if self._subprocess.returncode != 0:
|
||||||
logContent = ''
|
|
||||||
with open(self.logFile(), 'r') as logF:
|
with open(self.logFile(), 'r') as logF:
|
||||||
logContent = ''.join(logF.readlines())
|
logContent = ''.join(logF.readlines())
|
||||||
self.upgradeStatusTo(Status.ERROR)
|
self.upgradeStatusTo(Status.ERROR)
|
||||||
raise RuntimeError('Error on node "{}":\nLog:\n{}'.format(self.name, logContent))
|
raise RuntimeError('Error on node "{}":\nLog:\n{}'.format(self.name, logContent))
|
||||||
except:
|
except Exception:
|
||||||
self.upgradeStatusTo(Status.ERROR)
|
self.upgradeStatusTo(Status.ERROR)
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
elapsedTime = time.time() - startTime
|
elapsedTime = time.time() - startTime
|
||||||
print(' - elapsed time:', elapsedTime)
|
print(' - elapsed time:', elapsedTime)
|
||||||
self._subprocess = None
|
self._subprocess = None
|
||||||
# ask and wait for the stats thread to terminate
|
# ask and wait for the stats thread to stop
|
||||||
statThread.stopRequest()
|
statThread.stopRequest()
|
||||||
statThread.join()
|
statThread.join()
|
||||||
|
|
||||||
|
@ -793,6 +793,14 @@ class Graph(BaseObject):
|
||||||
""" Request graph execution to be stopped """
|
""" Request graph execution to be stopped """
|
||||||
self.stopExecutionRequested.emit()
|
self.stopExecutionRequested.emit()
|
||||||
|
|
||||||
|
def submittedNodes(self):
|
||||||
|
""" Return the list of submitted nodes inside this Graph """
|
||||||
|
return [node for node in self.nodes if node.isAlreadySubmitted()]
|
||||||
|
|
||||||
|
def clearSubmittedNodes(self):
|
||||||
|
""" Reset the status of already submitted nodes to Status.NONE """
|
||||||
|
[node.upgradeStatusTo(Status.NONE) for node in self.submittedNodes()]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def nodes(self):
|
def nodes(self):
|
||||||
return self._nodes
|
return self._nodes
|
||||||
|
@ -848,8 +856,13 @@ def execute(graph, toNodes=None, force=False):
|
||||||
node.beginSequence()
|
node.beginSequence()
|
||||||
|
|
||||||
for i, node in enumerate(nodes):
|
for i, node in enumerate(nodes):
|
||||||
print('\n[{i}/{N}] {nodeName}'.format(i=i+1, N=len(nodes), nodeName=node.nodeType()))
|
try:
|
||||||
node.process()
|
print('\n[{i}/{N}] {nodeName}'.format(i=i + 1, N=len(nodes), nodeName=node.nodeType))
|
||||||
|
node.process()
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("Error on node computation: {}".format(e))
|
||||||
|
graph.clearSubmittedNodes()
|
||||||
|
return
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
node.endSequence()
|
node.endSequence()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue