Compute or Submit selected nodes

This commit is contained in:
Aurore LAFAURIE 2024-07-05 15:28:10 +02:00
parent b173de5a73
commit 887844541c
4 changed files with 59 additions and 16 deletions

View file

@ -201,6 +201,9 @@ class TaskManager(BaseObject):
self.checkDuplicates(nodes, "COMPUTATION") # name of the context is important for QML self.checkDuplicates(nodes, "COMPUTATION") # name of the context is important for QML
nodes = [node for node in nodes if not self.contains(node)] # be sure to avoid non-real conflicts nodes = [node for node in nodes if not self.contains(node)] # be sure to avoid non-real conflicts
nodes = list(set(nodes))
nodes = sorted(nodes, key=lambda x: x.depth)
chunksInConflict = self.getAlreadySubmittedChunks(nodes) chunksInConflict = self.getAlreadySubmittedChunks(nodes)
if chunksInConflict: if chunksInConflict:

View file

@ -495,9 +495,10 @@ class UIGraph(QObject):
else: else:
self._undoStack.unlock() self._undoStack.unlock()
@Slot(QObjectListModel)
@Slot(Node) @Slot(Node)
def execute(self, node=None): def execute(self, nodes=None):
nodes = [node] if node else None nodes = [nodes] if not isinstance(nodes, Iterable) and nodes else nodes
self._taskManager.compute(self._graph, nodes) self._taskManager.compute(self._graph, nodes)
self.updateLockedUndoStack() # explicitly call the update while it is already computing self.updateLockedUndoStack() # explicitly call the update while it is already computing
@ -532,8 +533,9 @@ class UIGraph(QObject):
n.clearSubmittedChunks() n.clearSubmittedChunks()
self._taskManager.removeNode(n, displayList=True, processList=True) self._taskManager.removeNode(n, displayList=True, processList=True)
@Slot(QObjectListModel)
@Slot(Node) @Slot(Node)
def submit(self, node=None): def submit(self, nodes=None):
""" Submit the graph to the default Submitter. """ Submit the graph to the default Submitter.
If a node is specified, submit this node and its uncomputed predecessors. If a node is specified, submit this node and its uncomputed predecessors.
Otherwise, submit the whole Otherwise, submit the whole
@ -543,8 +545,8 @@ class UIGraph(QObject):
""" """
self.save() # graph must be saved before being submitted self.save() # graph must be saved before being submitted
self._undoStack.clear() # the undo stack must be cleared self._undoStack.clear() # the undo stack must be cleared
node = [node] if node else None nodes = [nodes] if not isinstance(nodes, Iterable) and nodes else nodes
self._taskManager.submit(self._graph, os.environ.get('MESHROOM_DEFAULT_SUBMITTER', ''), node, submitLabel=self.submitLabel) self._taskManager.submit(self._graph, os.environ.get('MESHROOM_DEFAULT_SUBMITTER', ''), nodes, submitLabel=self.submitLabel)
def updateGraphComputingStatus(self): def updateGraphComputingStatus(self):
# update graph computing status # update graph computing status

View file

@ -26,8 +26,8 @@ Item {
signal workspaceClicked() signal workspaceClicked()
signal nodeDoubleClicked(var mouse, var node) signal nodeDoubleClicked(var mouse, var node)
signal computeRequest(var node) signal computeRequest(var nodes)
signal submitRequest(var node) signal submitRequest(var nodes)
property int nbMeshroomScenes: 0 property int nbMeshroomScenes: 0
property int nbDraggedFiles: 0 property int nbDraggedFiles: 0
@ -455,6 +455,25 @@ Item {
computeRequest(nodeMenu.currentNode) computeRequest(nodeMenu.currentNode)
} }
} }
MenuItem {
text: "Compute Selected Node(s)"
visible: uigraph.selectedNodes.count > 0
height: visible ? implicitHeight : 0
enabled: {
var canCompute = false
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
if (uigraph.graph.canCompute(uigraph.selectedNodes.at(i)) && uigraph.graph.canSubmitOrCompute(uigraph.selectedNodes.at(i))%2 == 1){
canCompute = true
}
}
return canCompute
}
onTriggered: {
computeRequest(uigraph.selectedNodes)
}
}
MenuItem { MenuItem {
text: "Submit" text: "Submit"
enabled: nodeMenu.canComputeNode && nodeMenu.canSubmitOrCompute > 1 enabled: nodeMenu.canComputeNode && nodeMenu.canSubmitOrCompute > 1
@ -462,6 +481,25 @@ Item {
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0
onTriggered: submitRequest(nodeMenu.currentNode) onTriggered: submitRequest(nodeMenu.currentNode)
} }
MenuItem {
text: "Submit Selected Node(s)"
visible: uigraph.selectedNodes.count > 0
height: visible ? implicitHeight : 0
enabled: {
var canSubmit = false
for (var i = 0; i < uigraph.selectedNodes.count; ++i) {
if (uigraph.graph.canCompute(uigraph.selectedNodes.at(i)) && uigraph.graph.canSubmitOrCompute(uigraph.selectedNodes.at(i)) > 1){
canSubmit = true
}
}
return canSubmit
}
onTriggered: {
submitRequest(uigraph.selectedNodes)
}
}
MenuItem { MenuItem {
text: "Stop Computation" text: "Stop Computation"
enabled: nodeMenu.currentNode ? nodeMenu.currentNode.canBeStopped() : false enabled: nodeMenu.currentNode ? nodeMenu.currentNode.canBeStopped() : false

View file

@ -216,35 +216,35 @@ ApplicationWindow {
&& _reconstruction.graph.filepath : // graph is saved on disk && _reconstruction.graph.filepath : // graph is saved on disk
false false
function compute(node, force) { function compute(nodes, force) {
if (!force && warnIfUnsaved && !_reconstruction.graph.filepath) if (!force && warnIfUnsaved && !_reconstruction.graph.filepath)
{ {
unsavedComputeDialog.currentNode = node; unsavedComputeDialog.currentNode = nodes[0];
unsavedComputeDialog.open(); unsavedComputeDialog.open();
} }
else { else {
try { try {
_reconstruction.execute(node) _reconstruction.execute(nodes)
} }
catch (error) { catch (error) {
const data = ErrorHandler.analyseError(error) const data = ErrorHandler.analyseError(error)
if (data.context === "COMPUTATION") if (data.context === "COMPUTATION")
computeSubmitErrorDialog.openError(data.type, data.msg, node) computeSubmitErrorDialog.openError(data.type, data.msg, nodes)
} }
} }
} }
function submit(node) { function submit(nodes) {
if (!canSubmit) { if (!canSubmit) {
unsavedSubmitDialog.open() unsavedSubmitDialog.open()
} else { } else {
try { try {
_reconstruction.submit(node) _reconstruction.submit(nodes)
} }
catch (error) { catch (error) {
const data = ErrorHandler.analyseError(error) const data = ErrorHandler.analyseError(error)
if (data.context === "SUBMITTING") if (data.context === "SUBMITTING")
computeSubmitErrorDialog.openError(data.type, data.msg, node) computeSubmitErrorDialog.openError(data.type, data.msg, nodes)
} }
} }
} }
@ -1245,11 +1245,11 @@ ApplicationWindow {
} }
onComputeRequest: { onComputeRequest: {
_reconstruction.forceNodesStatusUpdate(); _reconstruction.forceNodesStatusUpdate();
computeManager.compute(node) computeManager.compute(nodes)
} }
onSubmitRequest: { onSubmitRequest: {
_reconstruction.forceNodesStatusUpdate(); _reconstruction.forceNodesStatusUpdate();
computeManager.submit(node) computeManager.submit(nodes)
} }
onFilesDropped: { onFilesDropped: {
var filesByType = _reconstruction.getFilesByTypeFromDrop(drop.urls) var filesByType = _reconstruction.getFilesByTypeFromDrop(drop.urls)