mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-24 20:17:17 +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:
|
if not args.save:
|
||||||
raise ValueError('Need to save the project to file to submit on renderfarm.')
|
raise ValueError('Need to save the project to file to submit on renderfarm.')
|
||||||
# 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:
|
elif args.compute:
|
||||||
# start computation
|
# start computation
|
||||||
taskManager = meshroom.core.taskManager.TaskManager()
|
taskManager = meshroom.core.taskManager.TaskManager()
|
||||||
|
|
|
@ -5,6 +5,7 @@ import meshroom
|
||||||
meshroom.setupEnvironment()
|
meshroom.setupEnvironment()
|
||||||
|
|
||||||
import meshroom.core.graph
|
import meshroom.core.graph
|
||||||
|
import meshroom.core.taskManager
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Submit a Graph of processes on renderfarm.')
|
parser = argparse.ArgumentParser(description='Submit a Graph of processes on renderfarm.')
|
||||||
parser.add_argument('meshroomFile', metavar='MESHROOMFILE.mg', type=str,
|
parser.add_argument('meshroomFile', metavar='MESHROOMFILE.mg', type=str,
|
||||||
|
@ -18,4 +19,5 @@ parser.add_argument('--submitter',
|
||||||
help='Execute job with a specific submitter.')
|
help='Execute job with a specific submitter.')
|
||||||
|
|
||||||
args = parser.parse_args()
|
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.load(filepath)
|
||||||
graph.update()
|
graph.update()
|
||||||
return graph
|
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
|
import meshroom
|
||||||
from meshroom.common import BaseObject, DictModel, Property, Signal, Slot
|
from meshroom.common import BaseObject, DictModel, Property, Signal, Slot
|
||||||
from meshroom.core.node import Status
|
from meshroom.core.node import Status
|
||||||
|
import meshroom.core.graph
|
||||||
|
|
||||||
|
|
||||||
class State(Enum):
|
class State(Enum):
|
||||||
|
@ -186,7 +187,8 @@ class TaskManager(BaseObject):
|
||||||
if chunksInConflict:
|
if chunksInConflict:
|
||||||
chunksStatus = set([chunk.status.status.name for chunk in chunksInConflict])
|
chunksStatus = set([chunk.status.status.name for chunk in chunksInConflict])
|
||||||
chunksName = [node.name for node 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' \
|
msg = '[COMPUTATION] Already Submitted:\n' \
|
||||||
'WARNING - Some nodes are already submitted with status: {}\nNodes: {}'.format(
|
'WARNING - Some nodes are already submitted with status: {}\nNodes: {}'.format(
|
||||||
', '.join(chunksStatus),
|
', '.join(chunksStatus),
|
||||||
|
@ -275,11 +277,23 @@ class TaskManager(BaseObject):
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# ensure submitter is properly set
|
# Ensure submitter is properly set
|
||||||
|
sub = None
|
||||||
|
if submitter:
|
||||||
sub = meshroom.core.submitters.get(submitter, None)
|
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:
|
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:
|
if self._thread._state != State.RUNNING:
|
||||||
self._nodes.clear()
|
self._nodes.clear()
|
||||||
|
|
||||||
|
@ -298,6 +312,9 @@ class TaskManager(BaseObject):
|
||||||
flowEdges = graph.flowEdges(startNodes=toNodes)
|
flowEdges = graph.flowEdges(startNodes=toNodes)
|
||||||
edgesToProcess = set(edgesToProcess).intersection(flowEdges)
|
edgesToProcess = set(edgesToProcess).intersection(flowEdges)
|
||||||
|
|
||||||
|
logging.info("Nodes to process: {}".format(nodesToProcess))
|
||||||
|
logging.info("Edges to process: {}".format(edgesToProcess))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
res = sub.submit(nodesToProcess, edgesToProcess, graph.filepath)
|
res = sub.submit(nodesToProcess, edgesToProcess, graph.filepath)
|
||||||
if res:
|
if res:
|
||||||
|
@ -309,6 +326,14 @@ class TaskManager(BaseObject):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("Error on submit : {}".format(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):
|
def getAlreadySubmittedChunks(self, nodes):
|
||||||
"""
|
"""
|
||||||
Check if nodes have already been submitted in another Meshroom instance.
|
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 import multiview
|
||||||
from meshroom.common.qt import QObjectListModel
|
from meshroom.common.qt import QObjectListModel
|
||||||
from meshroom.core.attribute import Attribute, ListAttribute
|
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
|
from meshroom.core.taskManager import TaskManager
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue