Skip to content

Commit 598b8d6

Browse files
committed
wip
1 parent f2d8092 commit 598b8d6

6 files changed

Lines changed: 22 additions & 24 deletions

File tree

bin/meshroom_compute

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,27 +141,26 @@ if args.node:
141141
if args.extern:
142142
# Restore the log level
143143
logging.getLogger().setLevel(meshroom.logStringToPython[args.verbose])
144-
145-
# Prepare logger
146-
node.prepareLogger(args.iteration)
147-
# Preprocess
148-
node.preprocess(args.forceCompute, args.inCurrentEnv)
149-
# Process
144+
150145
if args.iteration == ChunkIndex.NONE:
146+
# Process the whole node
151147
if node.nodeStatus.status == Status.STOPPED:
152148
print(f"Node {node}: status is STOPPED")
153149
killRunningJob(node)
150+
node.preprocess(args.forceCompute, args.inCurrentEnv)
151+
node.prepareLogger(args.iteration)
154152
node.process(args.forceCompute, args.inCurrentEnv)
153+
node.restoreLogger()
154+
node.postprocess(args.forceCompute, args.inCurrentEnv)
155155
else:
156156
chunk = chunks[0]
157157
if chunk._status.status == Status.STOPPED:
158158
print(f"Chunk {chunk}: status is STOPPED")
159159
killRunningJob(node)
160+
node.prepareLogger(args.iteration)
160161
chunk.process(args.forceCompute, args.inCurrentEnv)
161-
# Postprocess
162-
node.postprocess(args.forceCompute, args.inCurrentEnv)
163-
# Restore logger
164-
node.restoreLogger()
162+
node.restoreLogger()
163+
165164
else:
166165
if args.iteration != ChunkIndex.NONE:
167166
print('Error: "--iteration" only makes sense when used with "--node".')

bin/meshroom_createChunks

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ if not args.forceStatus and not args.forceCompute:
129129
f"submitterSessionUid: {node._nodeStatus.submitterSessionUid}")
130130

131131
if chunksToProcess:
132-
node.prepareLogger()
133132
node.preprocess()
133+
node.prepareLogger()
134134
for chunk in chunksToProcess:
135135
logging.info(f"[MeshroomCreateChunks] process chunk {chunk}")
136136
chunk.process(args.forceCompute, args.inCurrentEnv)
137-
node.postprocess()
138137
node.restoreLogger()
138+
node.postprocess()
139139
else:
140140
logging.info(f"[MeshroomCreateChunks] -> create job to process chunks {[c for c in node.chunks]}")
141141
submitter.createChunkTask(node, graphFile=args.graphFile, cache=args.cache,

meshroom/core/desc/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def processChunkInEnvironment(self, chunk):
426426
meshroomComputeCmd += f" --preprocess"
427427
elif chunk.isPostprocess:
428428
meshroomComputeCmd += f" --postprocess"
429-
elif len(chunk.node.getChunks()) > 1:
429+
elif len(chunk.node.getChunks()) >= 1:
430430
meshroomComputeCmd += f" --iteration {chunk.range.iteration}"
431431

432432
runtimeEnv = chunk.node.nodeDesc.plugin.runtimeEnv

meshroom/core/node.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,25 +408,22 @@ def makeProgressBar(self, end, message=''):
408408

409409
f.close()
410410

411-
with open(self.logFile) as f:
411+
with open(self.logFile, "r") as f:
412412
content = f.read()
413413
self.progressBarPosition = content.rfind('\n')
414414

415-
f.close()
416-
417415
def updateProgressBar(self, value):
418416
assert self.progressBar
419417
assert value <= self.progressEnd
420418

421419
tics = round((value/self.progressEnd)*51)
422420

423-
with open(self.logFile, 'r+') as f:
421+
with open(self.logFile, "r+") as f:
424422
text = f.read()
425423
for i in range(tics-self.currentProgressTics):
426424
text = text[:self.progressBarPosition]+'*'+text[self.progressBarPosition:]
427425
f.seek(0)
428426
f.write(text)
429-
f.close()
430427

431428
self.currentProgressTics = tics
432429

@@ -1719,9 +1716,10 @@ def processIteration(self, iteration):
17191716

17201717
def preprocess(self, forceCompute=False, inCurrentEnv=False):
17211718
""" Prepare the node processing """
1719+
self.prepareLogger(ChunkIndex.PREPROCESS)
17221720
if self.nodeDesc._hasPreprocess:
1723-
# self.nodeDesc.preprocess(self)
17241721
self._preprocessChunk.process(forceCompute, inCurrentEnv)
1722+
self.restoreLogger()
17251723

17261724
def process(self, forceCompute=False, inCurrentEnv=False):
17271725
for chunk in self._chunks:
@@ -1732,14 +1730,15 @@ def postprocess(self, forceCompute=False, inCurrentEnv=False):
17321730
Invoke the post process on Client Node to execute after the processing on the
17331731
node is completed
17341732
"""
1733+
self.prepareLogger(ChunkIndex.POSTPROCESS)
17351734
if self.nodeDesc._hasPostprocess:
1736-
# self.nodeDesc.postprocess(self)
17371735
self._postprocessChunk.process(forceCompute, inCurrentEnv)
1736+
self.restoreLogger()
17381737

17391738
def getLogHandlers(self):
17401739
return self._handlers
17411740

1742-
def prepareLogger(self, iteration=-1):
1741+
def prepareLogger(self, iteration=ChunkIndex.NONE):
17431742
# Get file handler path
17441743
chunkName = self.getChunkName(iteration)
17451744
logFileName = f"{chunkName}.log"

meshroom/ui/qml/Utils/Colors.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ QtObject {
5252
]
5353

5454
function getChunkColor(chunk, overrides) {
55-
if (chunk === undefined)
55+
if (chunk === undefined || chunk == null)
5656
return "transparent"
5757
if (overrides && chunk.statusName in overrides) {
5858
return overrides[chunk.statusName]

tests/test_compute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@
2323
def executeChunks(node, size):
2424
os.makedirs(node.internalFolder)
2525
logFiles = {}
26+
node.preprocess()
2627
for chunkIndex in range(size):
2728
iteration = chunkIndex if size > 1 else -1
2829
logFileName = f"{chunkIndex}.log"
2930
logFile = Path(node.internalFolder) / logFileName
3031
logFiles[chunkIndex] = logFile
3132
logFile.touch()
3233
node.prepareLogger(iteration)
33-
node.preprocess()
3434
if size > 1:
3535
chunk = node.chunks[chunkIndex]
3636
chunk.process(True, True)
3737
else:
3838
node.process(True, True)
39-
node.postprocess()
4039
node.restoreLogger()
40+
node.postprocess()
4141
return logFiles
4242

4343

0 commit comments

Comments
 (0)