Skip to content

Commit a551c38

Browse files
committed
[ui][submitter] Add possibility to switch the submitter in the UI
1 parent 583e9ee commit a551c38

File tree

6 files changed

+46
-7
lines changed

6 files changed

+46
-7
lines changed

meshroom/submitters/tractorApi/__init__.py

Whitespace-only changes.
File renamed without changes.

meshroom/submitters/tractorSubmitter.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88

99
from meshroom.core.submitter import BaseSubmitter
1010

11-
try:
12-
import submitters.tractorApi as tractorApi
13-
except ImportError:
14-
import tractorApi
15-
11+
import meshroom.submitters.tractorApi.api as tractorApi
12+
1613

1714
currentDir = os.path.dirname(os.path.realpath(__file__))
1815
binDir = os.path.dirname(os.path.dirname(os.path.dirname(currentDir)))

meshroom/ui/app.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import meshroom
1616
from meshroom.core import pluginManager
17+
from meshroom.core.submitter import BaseSubmitter
1718
from meshroom.core.taskManager import TaskManager
1819
from meshroom.common import Property, Variant, Signal, Slot
1920

@@ -265,6 +266,7 @@ def __init__(self, inputArgs):
265266

266267
# instantiate Reconstruction object
267268
self._undoStack = commands.UndoStack(self)
269+
self._defaultSubmitterName = os.environ.get('MESHROOM_DEFAULT_SUBMITTER', '')
268270
self._taskManager = TaskManager(self)
269271
self._activeProject = Reconstruction(undoStack=self._undoStack, taskManager=self._taskManager, defaultPipeline=args.pipeline, parent=self)
270272
self._activeProject.setSubmitLabel(args.submitLabel)
@@ -698,7 +700,28 @@ def _getEnvironmentVariableValue(self, key: str, defaultValue: bool) -> bool:
698700
if val != True and str(val).lower() in ("0", "false", "off"):
699701
return False
700702
return True
701-
703+
704+
def _submittersList(self):
705+
"""
706+
Get the list of available submitters
707+
Model provides :
708+
name : the name of the submitter
709+
isDefault : True if this is the current submitter
710+
"""
711+
submittersList = []
712+
for s in meshroom.core.submitters:
713+
submitterName = s.name if isinstance(s, BaseSubmitter) else s
714+
submittersList.append({
715+
"name": submitterName,
716+
"isDefault": True if submitterName == self._defaultSubmitterName else False
717+
})
718+
return submittersList
719+
720+
@Slot(str)
721+
def setDefaultSubmitter(self, name):
722+
logging.warning(f"Submitter is now set to : {name}")
723+
self._defaultSubmitterName = name
724+
702725
activeProjectChanged = Signal()
703726
activeProject = Property(Variant, lambda self: self._activeProject, notify=activeProjectChanged)
704727

@@ -713,3 +736,4 @@ def _getEnvironmentVariableValue(self, key: str, defaultValue: bool) -> bool:
713736
recentImportedImagesFolders = Property("QVariantList", _recentImportedImagesFolders, notify=recentImportedImagesFoldersChanged)
714737
default8bitViewerEnabled = Property(bool, _default8bitViewerEnabled, constant=True)
715738
defaultSequencePlayerEnabled = Property(bool, _defaultSequencePlayerEnabled, constant=True)
739+
submittersListModel = Property("QVariantList", _submittersList, constant=True)

meshroom/ui/graph.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,9 @@ def submit(self, nodes: Optional[Union[list[Node], Node]] = None):
585585
self.save() # graph must be saved before being submitted
586586
self._undoStack.clear() # the undo stack must be cleared
587587
nodes = [nodes] if not isinstance(nodes, Iterable) and nodes else nodes
588-
self._taskManager.submit(self._graph, os.environ.get('MESHROOM_DEFAULT_SUBMITTER', ''), nodes, submitLabel=self.submitLabel)
588+
mrDefaultSubmitter = os.environ.get('MESHROOM_DEFAULT_SUBMITTER', '')
589+
chosenSubmitter = self.parent()._defaultSubmitterName or mrDefaultSubmitter
590+
self._taskManager.submit(self._graph, chosenSubmitter, nodes, submitLabel=self.submitLabel)
589591

590592
def updateGraphComputingStatus(self):
591593
# update graph computing status

meshroom/ui/qml/Application.qml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,22 @@ Page {
928928
onTriggered: _reconstruction.stopExecution()
929929
enabled: _reconstruction ? _reconstruction.computingLocally : false
930930
}
931+
MenuSeparator {}
932+
Menu {
933+
id: submitterSelectionMenu
934+
title: "Submitter selection"
935+
enabled: submitterItems.model !== undefined && submitterItems.model.length > 0
936+
Repeater {
937+
id: submitterItems
938+
model: MeshroomApp.submittersListModel
939+
RadioButton {
940+
text: modelData["name"]
941+
checked: modelData["isDefault"]
942+
// checked: MeshroomApp.submittersListModel[0]["name"] == modelData["name"]
943+
onClicked: MeshroomApp.setDefaultSubmitter(modelData["name"])
944+
}
945+
}
946+
}
931947
}
932948
Menu {
933949
title: "Help"

0 commit comments

Comments
 (0)