From e3815f74c762d9642776c781fd91738c4c46daa2 Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Tue, 21 Nov 2017 12:24:16 +0100 Subject: [PATCH] [core] check RUNNING status in chunk compute function and add option to force computation --- bin/meshroom_compute | 10 ++-------- meshroom/core/graph.py | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/bin/meshroom_compute b/bin/meshroom_compute index 78115ae7..d880d33f 100755 --- a/bin/meshroom_compute +++ b/bin/meshroom_compute @@ -50,15 +50,9 @@ if args.node: # exit(-1) if args.iteration != -1: chunk = node.chunks[args.iteration] - if chunk.status.status != Status.SUCCESS or args.forceCompute: - chunk.process() - else: - print('Node chunk is already successfully computed. Nothing to do.') + chunk.process(args.forceCompute) else: - if not node.hasStatus(Status.SUCCESS) or args.forceCompute: - node.process() - else: - print('Node is already successfully computed. Nothing to do.') + node.process(args.forceCompute) else: if args.iteration != -1: print('Error: "--iteration" only make sense when used with "--node".') diff --git a/meshroom/core/graph.py b/meshroom/core/graph.py index 467e3515..8228574c 100644 --- a/meshroom/core/graph.py +++ b/meshroom/core/graph.py @@ -570,7 +570,10 @@ class NodeChunk(BaseObject): def isAlreadySubmitted(self): return self.status.status in (Status.SUBMITTED_EXTERN, Status.SUBMITTED_LOCAL, Status.RUNNING) - def process(self): + def process(self, forceCompute=False): + if not forceCompute and self.status.status == Status.SUCCESS: + print("Node chunk already computed:", self.name) + return global runningProcesses runningProcesses[self.name] = self self.upgradeStatusTo(Status.RUNNING) @@ -845,9 +848,9 @@ class Node(BaseObject): def processIteration(self, iteration): self.chunks[iteration].process() - def process(self): + def process(self, forceCompute=False): for chunk in self.chunks: - chunk.process() + chunk.process(forceCompute) def endSequence(self): pass @@ -1437,10 +1440,18 @@ def execute(graph, toNodes=None, forceCompute=False, forceStatus=False): for node in nodes: node.beginSequence() - for i, node in enumerate(nodes): + for n, node in enumerate(nodes): try: - print('\n[{i}/{N}] {nodeName}'.format(i=i + 1, N=len(nodes), nodeName=node.nodeType)) - node.process() + multiChunks = len(node.chunks) > 1 + for c, chunk in enumerate(node.chunks): + if multiChunks: + print('\n[{node}/{nbNodes}]({chunk}/{nbChunks}) {nodeName}'.format( + node=n+1, nbNodes=len(nodes), + chunk=c+1, nbChunks=len(node.chunks), nodeName=node.nodeType)) + else: + print('\n[{node}/{nbNodes}] {nodeName}'.format( + node=n + 1, nbNodes=len(nodes), nodeName=node.nodeType)) + chunk.process(forceCompute) except Exception as e: logging.error("Error on node computation: {}".format(e)) graph.clearSubmittedNodes()