mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-23 11:37:28 +02:00
[core/bin] Submitting: remove a duplicate function and move another one
This commit is contained in:
parent
78f7febeb7
commit
3f3a6c0e83
5 changed files with 35 additions and 48 deletions
|
@ -198,7 +198,8 @@ if args.submit:
|
|||
if not args.save:
|
||||
raise ValueError('Need to save the project to file to submit on renderfarm.')
|
||||
# submit on renderfarm
|
||||
meshroom.core.graph.submit(args.save, args.submitter, toNode=toNodes)
|
||||
taskManager = meshroom.core.taskManager.TaskManager()
|
||||
taskManager.submitFromFile(args.save, args.submitter, toNode=toNodes)
|
||||
elif args.compute:
|
||||
# start computation
|
||||
taskManager = meshroom.core.taskManager.TaskManager()
|
||||
|
|
|
@ -5,6 +5,7 @@ import meshroom
|
|||
meshroom.setupEnvironment()
|
||||
|
||||
import meshroom.core.graph
|
||||
import meshroom.core.taskManager
|
||||
|
||||
parser = argparse.ArgumentParser(description='Submit a Graph of processes on renderfarm.')
|
||||
parser.add_argument('meshroomFile', metavar='MESHROOMFILE.mg', type=str,
|
||||
|
@ -18,4 +19,5 @@ parser.add_argument('--submitter',
|
|||
help='Execute job with a specific submitter.')
|
||||
|
||||
args = parser.parse_args()
|
||||
meshroom.core.graph.submit(args.meshroomFile, args.submitter, toNode=args.toNode)
|
||||
taskManager = meshroom.core.taskManager.TaskManager()
|
||||
taskManager.submitFromFile(args.meshroomFile, args.submitter, toNode=args.toNode)
|
||||
|
|
|
@ -1173,44 +1173,3 @@ def loadGraph(filepath):
|
|||
graph.load(filepath)
|
||||
graph.update()
|
||||
return graph
|
||||
|
||||
|
||||
def submitGraph(graph, submitter, toNodes=None):
|
||||
nodesToProcess, edgesToProcess = graph.dfsToProcess(startNodes=toNodes)
|
||||
flowEdges = graph.flowEdges(startNodes=toNodes)
|
||||
edgesToProcess = set(edgesToProcess).intersection(flowEdges)
|
||||
|
||||
if not nodesToProcess:
|
||||
logging.warning('Nothing to compute')
|
||||
return
|
||||
|
||||
logging.info("Nodes to process: {}".format(edgesToProcess))
|
||||
logging.info("Edges to process: {}".format(edgesToProcess))
|
||||
|
||||
sub = None
|
||||
if submitter:
|
||||
sub = meshroom.core.submitters.get(submitter, None)
|
||||
elif len(meshroom.core.submitters) == 1:
|
||||
# if only one submitter available use it
|
||||
sub = meshroom.core.submitters.values()[0]
|
||||
if sub is None:
|
||||
raise RuntimeError("Unknown Submitter: '{submitter}'. Available submitters are: '{allSubmitters}'.".format(
|
||||
submitter=submitter, allSubmitters=str(meshroom.core.submitters.keys())))
|
||||
|
||||
try:
|
||||
res = sub.submit(nodesToProcess, edgesToProcess, graph.filepath)
|
||||
if res:
|
||||
for node in nodesToProcess:
|
||||
node.submit() # update node status
|
||||
except Exception as e:
|
||||
logging.error("Error on submit : {}".format(e))
|
||||
|
||||
|
||||
def submit(graphFile, submitter, toNode=None):
|
||||
"""
|
||||
Submit the given graph via the given submitter.
|
||||
"""
|
||||
graph = loadGraph(graphFile)
|
||||
toNodes = graph.findNodes([toNode]) if toNode else None
|
||||
submitGraph(graph, submitter, toNodes)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from enum import Enum
|
|||
import meshroom
|
||||
from meshroom.common import BaseObject, DictModel, Property, Signal, Slot
|
||||
from meshroom.core.node import Status
|
||||
import meshroom.core.graph
|
||||
|
||||
|
||||
class State(Enum):
|
||||
|
@ -186,7 +187,8 @@ class TaskManager(BaseObject):
|
|||
if chunksInConflict:
|
||||
chunksStatus = set([chunk.status.status.name for chunk in chunksInConflict])
|
||||
chunksName = [node.name for node in chunksInConflict]
|
||||
# Syntax and terms are used on QML side to recognize the error
|
||||
# Warning: Syntax and terms are parsed on QML side to recognize the error
|
||||
# Syntax : [Context] ErrorType: ErrorMessage
|
||||
msg = '[COMPUTATION] Already Submitted:\n' \
|
||||
'WARNING - Some nodes are already submitted with status: {}\nNodes: {}'.format(
|
||||
', '.join(chunksStatus),
|
||||
|
@ -275,11 +277,23 @@ class TaskManager(BaseObject):
|
|||
:return:
|
||||
"""
|
||||
|
||||
# ensure submitter is properly set
|
||||
# Ensure submitter is properly set
|
||||
sub = None
|
||||
if submitter:
|
||||
sub = meshroom.core.submitters.get(submitter, None)
|
||||
elif len(meshroom.core.submitters) == 1:
|
||||
# if only one submitter available use it
|
||||
sub = list(meshroom.core.submitters.values())[0]
|
||||
if sub is None:
|
||||
raise RuntimeError("Unknown Submitter : " + submitter)
|
||||
# Warning: Syntax and terms are parsed on QML side to recognize the error
|
||||
# Syntax : [Context] ErrorType: ErrorMessage
|
||||
raise RuntimeError("[SUBMITTING] Unknown Submitter:\n"
|
||||
"Unknown Submitter called '{submitter}'. Available submitters are: '{allSubmitters}'.".format(
|
||||
submitter=submitter,
|
||||
allSubmitters=str(meshroom.core.submitters.keys())
|
||||
))
|
||||
|
||||
# Update task manager's lists
|
||||
if self._thread._state != State.RUNNING:
|
||||
self._nodes.clear()
|
||||
|
||||
|
@ -298,6 +312,9 @@ class TaskManager(BaseObject):
|
|||
flowEdges = graph.flowEdges(startNodes=toNodes)
|
||||
edgesToProcess = set(edgesToProcess).intersection(flowEdges)
|
||||
|
||||
logging.info("Nodes to process: {}".format(nodesToProcess))
|
||||
logging.info("Edges to process: {}".format(edgesToProcess))
|
||||
|
||||
try:
|
||||
res = sub.submit(nodesToProcess, edgesToProcess, graph.filepath)
|
||||
if res:
|
||||
|
@ -309,6 +326,14 @@ class TaskManager(BaseObject):
|
|||
except Exception as e:
|
||||
logging.error("Error on submit : {}".format(e))
|
||||
|
||||
def submitFromFile(self, graphFile, submitter, toNode=None):
|
||||
"""
|
||||
Submit the given graph via the given submitter.
|
||||
"""
|
||||
graph = meshroom.core.graph.loadGraph(graphFile)
|
||||
toNodes = graph.findNodes([toNode]) if toNode else None
|
||||
self.submit(graph, submitter, toNodes)
|
||||
|
||||
def getAlreadySubmittedChunks(self, nodes):
|
||||
"""
|
||||
Check if nodes have already been submitted in another Meshroom instance.
|
||||
|
|
|
@ -12,7 +12,7 @@ from PySide2.QtCore import Slot, QJsonValue, QObject, QUrl, Property, Signal, QP
|
|||
from meshroom import multiview
|
||||
from meshroom.common.qt import QObjectListModel
|
||||
from meshroom.core.attribute import Attribute, ListAttribute
|
||||
from meshroom.core.graph import Graph, Edge, submitGraph
|
||||
from meshroom.core.graph import Graph, Edge
|
||||
|
||||
from meshroom.core.taskManager import TaskManager
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue