Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Several Compatibility Nodes Operations #2506

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions meshroom/core/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,9 +1132,10 @@ def finishEdge(edge, graph):
return nodes, edges

@Slot(Node, result=bool)
def canCompute(self, node):
def canComputeTopologically(self, node):
"""
Return the computability of a node based on itself and its dependency chain.
It is a static result as it depends on the graph topology.
Computation can't happen for:
- CompatibilityNodes
- nodes having a non-computed CompatibilityNode in its dependency chain
Expand Down Expand Up @@ -1200,7 +1201,7 @@ def finishEdge(edge, graph):
self.dfs(visitor=visitor, startNodes=leaves)

# update graph computability status
canComputeLeaves = all([self.canCompute(node) for node in leaves])
canComputeLeaves = all([self.canComputeTopologically(node) for node in leaves])
if self._canComputeLeaves != canComputeLeaves:
self._canComputeLeaves = canComputeLeaves
self.canComputeLeavesChanged.emit()
Expand Down Expand Up @@ -1290,6 +1291,7 @@ def getOutputNodes(self, node, recursive, dependenciesOnly):
def canSubmitOrCompute(self, startNode):
"""
Check if a node can be submitted/computed.
It does not depend on the topology of the graph and is based on the node status and its dependencies.

Returns:
int: 0 = cannot be submitted or computed /
Expand Down
4 changes: 2 additions & 2 deletions meshroom/core/taskManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ def checkNodesDependencies(self, graph, toNodes, context):
if not node.isComputable:
inputNodes.append(node)
elif context == "COMPUTATION":
if graph.canCompute(node) and graph.canSubmitOrCompute(node) % 2 == 1:
if graph.canComputeTopologically(node) and graph.canSubmitOrCompute(node) % 2 == 1:
ready.append(node)
elif node.isComputed:
computed.append(node)
elif context == "SUBMITTING":
if graph.canCompute(node) and graph.canSubmitOrCompute(node) > 1:
if graph.canComputeTopologically(node) and graph.canSubmitOrCompute(node) > 1:
ready.append(node)
elif node.isComputed:
computed.append(node)
Expand Down
22 changes: 15 additions & 7 deletions meshroom/ui/qml/GraphEditor/GraphEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ Item {
Menu {
id: nodeMenu
property var currentNode: null
property bool canComputeNode: currentNode != null && uigraph.graph.canCompute(currentNode)
property bool canComputeNode: currentNode != null && uigraph.graph.canComputeTopologically(currentNode)
//canSubmitOrCompute: return int n : 0 >= n <= 3 | n=0 cannot submit or compute | n=1 can compute | n=2 can submit | n=3 can compute & submit
property int canSubmitOrCompute: currentNode != null && uigraph.graph.canSubmitOrCompute(currentNode)
property bool isComputed: {
Expand Down Expand Up @@ -584,11 +584,15 @@ Item {
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
if (uigraph.graph.canComputeTopologically(uigraph.selectedNodes.at(i))) {
if (nodeMenu.isComputed) {
canCompute = true
} else if (uigraph.graph.canSubmitOrCompute(uigraph.selectedNodes.at(i)) % 2 == 1) {
canCompute = true
}
}
}
return canCompute || nodeMenu.isComputed //canSubmit if canSubmitOrCompute == 1(can compute) or 3(can compute & submit)
return canCompute //canSubmit if canSubmitOrCompute == 1(can compute) or 3(can compute & submit)

}

Expand Down Expand Up @@ -617,11 +621,15 @@ Item {
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
if (uigraph.graph.canComputeTopologically(uigraph.selectedNodes.at(i))) {
if (nodeMenu.isComputed) {
canSubmit = true
} else if (uigraph.graph.canSubmitOrCompute(uigraph.selectedNodes.at(i)) > 1) {
canSubmit = true
}
}
}
return canSubmit || nodeMenu.isComputed
return canSubmit
}
onTriggered: {
if (nodeMenu.isComputed) {
Expand Down
Loading