Skip to content

Commit

Permalink
added build badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Hog committed Sep 12, 2024
1 parent f1edbb1 commit b7f9a2f
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 86 deletions.
33 changes: 21 additions & 12 deletions meshroom/core/desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,16 +658,21 @@ class Node(object):
documentation = ''
category = 'Other'

_isPlugin = True

def __init__(self):
super(Node, self).__init__()
self.hasDynamicOutputAttribute = any(output.isDynamicValue for output in self.outputs)
try:
self.envFile
self.envType
except:
self._isPlugin=False

@property
def envType(cls):
"""
Env type used for plugins
"""
raise NotImplementedError("You must specify one or several envtype in the node description")
from core.plugin import EnvType #lazy import for plugin to avoid circular dependency
return EnvType.NONE

@property
def envFile(cls):
Expand All @@ -686,16 +691,20 @@ def _envName(cls):
from meshroom.core.plugin import getEnvName #lazy import as to avoid circular dep
return getEnvName(envContent)

def isPlugin(cls):
@property
def isPlugin(self):
"""
Tests if the node is a valid plugin node
"""
try:
cls.envFile
cls.envType
except:
return False
return True
return self._isPlugin

@property
def isBuilt(self):
"""
Tests if the envirronement is built
"""
from meshroom.core.plugin import isBuilt
return self._isPlugin and isBuilt(self)

def upgradeAttributeValues(self, attrValues, fromVersion):
return attrValues
Expand Down Expand Up @@ -767,7 +776,7 @@ def buildCommandLine(self, chunk):
#the process in Popen does not seem to use the right python, even if meshroom_compute is called within the env
#so in the case of command line using python, we have to make sure it is using the correct python
from meshroom.core.plugin import EnvType, getVenvPath, getVenvExe #lazy import to prevent circular dep
if self.isPlugin() and self.envType == EnvType.VENV:
if self.isPlugin and self.envType == EnvType.VENV:
envPath = getVenvPath(self._envName)
envExe = getVenvExe(envPath)
cmd=cmd.replace("python", envExe)
Expand Down
5 changes: 4 additions & 1 deletion meshroom/core/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,8 @@ def upgradeNode(self, nodeName):
logging.warning("Failed to restore edge {} -> {}: {}".format(src, dst, str(e)))

return upgradedNode, inEdges, outEdges, outListAttributes



def upgradeAllNodes(self):
""" Upgrade all upgradable CompatibilityNode instances in the graph. """
nodeNames = [name for name, n in self._compatibilityNodes.items() if n.canUpgrade]
Expand Down Expand Up @@ -1115,6 +1116,8 @@ def canCompute(self, node):
"""
if isinstance(node, CompatibilityNode):
return False
# if node.nodeDesc.isPlugin:
# return node.nodeDesc.isBuilt
return not self._computationBlocked[node]

def updateNodesTopologicalData(self):
Expand Down
10 changes: 7 additions & 3 deletions meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,10 @@ def process(self, forceCompute=False):

#if plugin node and if first call call meshroom_compute inside the env on 'host' so that the processchunk
# of the node will be ran into the env
if self.node.nodeDesc.isPlugin() and self._status.status!=Status.FIRST_RUN:
if self.node.nodeDesc.isPlugin and self._status.status!=Status.FIRST_RUN:
try:
from meshroom.core.plugin import isBuild, build, getCommandLine #lazy import to avoid circular dep
if not isBuild(self.node.nodeDesc):
from meshroom.core.plugin import isBuilt, build, getCommandLine #lazy import to avoid circular dep
if not isBuilt(self.node.nodeDesc):
self.upgradeStatusTo(Status.BUILD)
build(self.node.nodeDesc)
self.upgradeStatusTo(Status.FIRST_RUN)
Expand Down Expand Up @@ -482,6 +482,7 @@ def isExtern(self):
statusNodeName = Property(str, lambda self: self._status.nodeName, constant=True)

elapsedTime = Property(float, lambda self: self._status.elapsedTime, notify=statusChanged)



# simple structure for storing node position
Expand Down Expand Up @@ -1395,6 +1396,9 @@ def has3DOutputAttribute(self):
hasSequenceOutput = Property(bool, hasSequenceOutputAttribute, notify=outputAttrEnabledChanged)
has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged)

isPlugin = Property(bool, lambda self: self.nodeDesc.isPlugin, constant=True)
isBuilt = Property(bool, lambda self: self.nodeDesc.isBuilt, constant=True)

Check notice on line 1400 in meshroom/core/node.py

View check run for this annotation

codefactor.io / CodeFactor

meshroom/core/node.py#L1400

Multiple spaces before operator. (E221)

Check notice on line 1400 in meshroom/core/node.py

View check run for this annotation

codefactor.io / CodeFactor

meshroom/core/node.py#L1400

Multiple spaces after ','. (E241)

class Node(BaseNode):
"""
A standard Graph node based on a node type.
Expand Down
5 changes: 4 additions & 1 deletion meshroom/core/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def uninstallPlugin(pluginUrl):
else:
os.removedirs(pluginUrl)

def isBuild(nodeDesc):
def isBuilt(nodeDesc):
"""
Check if the env needs to be build for a specific nodesc.
"""
Expand All @@ -233,6 +233,7 @@ def build(nodeDesc):
"""
if not hasattr(nodeDesc, 'envFile'):
raise RuntimeError("The nodedesc has no env file")
returnValue = 0
if nodeDesc.envType == EnvType.NONE:
pass
elif nodeDesc.envType == EnvType.PIP:
Expand Down Expand Up @@ -280,6 +281,8 @@ def build(nodeDesc):
logging.info("Building with "+buildCommand+" ...")
returnValue = os.system(buildCommand)
logging.info("Done")
else:
raise RuntimeError("Invalid env type")
if returnValue != 0:
raise RuntimeError("Something went wrong during build")

Expand Down
96 changes: 96 additions & 0 deletions meshroom/ui/qml/Application.qml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,73 @@ Page {
}
}

//File browser for plugin
Dialog {
id: pluginURLDialog
title: "Plugin URL"
height: 150
width: 300
standardButtons: StandardButton.Ok | StandardButton.Cancel
//focus: true
Column {
anchors.fill: parent
Text {
text: "Plugin URL"
height: 40
}
TextField {
id: urlInput
width: parent.width * 0.75
focus: true
}
}
onButtonClicked: {
if (clickedButton==StandardButton.Ok) {
console.log("Accepted " + clickedButton)
if (_reconstruction.installPlugin(urlInput.text)) {
pluginInstalledDialog.open()
} else {
pluginNotInstalledDialog.open()
}
}
}
}

// dialogs for plugins
MessageDialog {
id: pluginInstalledDialog
title: "Plugin installed"
modal: true
canCopy: false
Label {
text: "Plugin installed, please restart meshroom for the changes to take effect"
}
}

MessageDialog {
id: pluginNotInstalledDialog
title: "Plugin not installed"
modal: true
canCopy: false
Label {
text: "Something went wrong, plugin not installed"
}
}

// plugin installation from path or url
Platform.FolderDialog {
id: intallPluginDialog
options: Platform.FolderDialog.DontUseNativeDialog
title: "Install Plugin"
onAccepted: {
if (_reconstruction.installPlugin(currentFolder.toString())) {
pluginInstalledDialog.open()
} else {
pluginNotInstalledDialog.open()
}
}
}

Item {
id: computeManager

Expand Down Expand Up @@ -560,6 +627,23 @@ Page {
}
}

Action {
id: installPluginFromFolderAction
text: "Install Plugin From Local Folder"
onTriggered: {
initFileDialogFolder(intallPluginDialog)
intallPluginDialog.open()
}
}

Action {
id: installPluginFromURLAction
text: "Install Plugin From URL"
onTriggered: {
pluginURLDialog.open()
}
}

header: RowLayout {
spacing: 0
MaterialToolButton {
Expand Down Expand Up @@ -1272,6 +1356,18 @@ Page {
var n = _reconstruction.upgradeNode(node)
_reconstruction.selectedNode = n
}

onDoBuild: {
try {
_reconstruction.buildNode(node.name)
node.isNotBuilt=false
} catch (error) {
//NOTE: could do an error popup
console.log("Build error:")
console.log(error)
}

}
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion meshroom/ui/qml/GraphEditor/Node.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Item {
property bool readOnly: node.locked
/// Whether the node is in compatibility mode
readonly property bool isCompatibilityNode: node ? node.hasOwnProperty("compatibilityIssue") : false
/// Whether the node is a plugin that needs to be build
readonly property bool isPlugin: node ? node.isPlugin : false
property bool isNotBuilt: node ? (!node.isBuilt) : false
/// Mouse related states
property bool mainSelected: false
property bool selected: false
Expand All @@ -28,7 +31,8 @@ Item {
property point position: Qt.point(x, y)
/// Styling
property color shadowColor: "#cc000000"
readonly property color defaultColor: isCompatibilityNode ? "#444" : !node.isComputable ? "#BA3D69" : activePalette.base
//readonly property color defaultColor: isCompatibilityNode ? "#444" : ((isPlugin && isNotBuilt) ? "#444": (!node.isComputable ? "#BA3D69" : activePalette.base))
readonly property color defaultColor: isCompatibilityNode ? "#444" : (!node.isComputable ? "#BA3D69" : activePalette.base)
property color baseColor: defaultColor

property point mousePosition: Qt.point(mouseArea.mouseX, mouseArea.mouseY)
Expand Down Expand Up @@ -240,6 +244,15 @@ Item {
issueDetails: root.node.issueDetails
}
}

// ToBuild icon for PluginNodes
Loader {
active: root.isPlugin && root.isNotBuilt
sourceComponent: ToBuildBadge {
sourceComponent: iconDelegate
}
}


// Data sharing indicator
// Note: for an unknown reason, there are some performance issues with the UI refresh.
Expand Down
14 changes: 14 additions & 0 deletions meshroom/ui/qml/GraphEditor/NodeEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ Panel {
property bool readOnly: false
property bool isCompatibilityNode: node && node.compatibilityIssue !== undefined
property string nodeStartDateTime: ""
readonly property bool isPlugin: node ? node.isPlugin : false
readonly property bool isNotBuilt: node ? (!node.isBuilt) : false

signal attributeDoubleClicked(var mouse, var attribute)
signal upgradeRequest()
signal doBuild()

title: "Node" + (node !== null ? " - <b>" + node.label + "</b>" + (node.label !== node.defaultLabel ? " (" + node.defaultLabel + ")" : "") : "")
icon: MaterialLabel { text: MaterialIcons.tune }
Expand Down Expand Up @@ -226,6 +229,17 @@ Panel {
}
}

Loader {
active: root.isPlugin && root.isNotBuilt
Layout.fillWidth: true
visible: active // for layout update

sourceComponent: ToBuildBadge {
onDoBuild: root.doBuild()
sourceComponent: bannerDelegate
}
}

Loader {
Layout.fillHeight: true
Layout.fillWidth: true
Expand Down
3 changes: 2 additions & 1 deletion meshroom/ui/qml/GraphEditor/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ AttributePin 1.0 AttributePin.qml
AttributeEditor 1.0 AttributeEditor.qml
AttributeItemDelegate 1.0 AttributeItemDelegate.qml
CompatibilityBadge 1.0 CompatibilityBadge.qml
ToBuildBadge 1.0 ToBuildBadge.qml
CompatibilityManager 1.0 CompatibilityManager.qml
singleton GraphEditorSettings 1.0 GraphEditorSettings.qml
TaskManager 1.0 TaskManager.qml
ScriptEditor 1.0 ScriptEditor.qml
ScriptEditor 1.0 ScriptEditor.qml
Loading

0 comments on commit b7f9a2f

Please sign in to comment.