Skip to content

Commit

Permalink
Merge pull request #1683 from willend/main
Browse files Browse the repository at this point in the history
Allow to configure and use Monitor_nD buffersize from mcgui and mcrun.
  • Loading branch information
willend authored Aug 31, 2024
2 parents cf07d5f + c28a183 commit ab7456e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
1 change: 1 addition & 0 deletions tools/Python/mccodelib/mccode_config.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"BROWSER": "@BROWSER@",
"GUICOLS": "3",
"GUIFONTSIZE": "12",
"NDBUFFERSIZE": "10000000",
"EDITOR": "@EDITOR@",
"FORMAT": "McCode",
"ISCONDAPKG": "@MCCODE_IS_CONDA_PKG@"
Expand Down
10 changes: 8 additions & 2 deletions tools/Python/mcgui/mcgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ def run(self, fixed_params, params, inspect=None):
7 - output directory (str)
8 - autoplotter
9 - format
10 - Monitor_nD buffersize
params[]:
[<par_name>, <value>] pairs
'''
Expand Down Expand Up @@ -411,7 +412,12 @@ def run(self, fixed_params, params, inspect=None):
if Format and simtrace == 0:
print("REDEFINING FORMAT: " + mccode_config.configuration["FORMAT"])
runstr = runstr + ' --format=' + mccode_config.configuration["FORMAT"]


# Monitor_nD buffersize
Bufsiz = fixed_params[10]
if Bufsiz and simtrace == 0:
runstr = runstr + ' --bufsiz=' + Bufsiz

# parse instrument params
for p in params:
runstr = runstr + ' ' + p[0] + '=' + p[1]
Expand Down Expand Up @@ -652,7 +658,7 @@ def get_compnames(text):
comps = get_compnames(text=open(self.state.getInstrumentFile(), 'rb').read().decode())
_a, mcplots, mcdisplays, formats = mccode_config.get_options()
fixed_params, new_instr_params, inspect, mcdisplay, autoplotter, Format = self.view.showStartSimDialog(
instr_params, comps, mcdisplays, mcplots, formats)
instr_params, comps, mcdisplays, mcplots, formats, mccode_config.configuration["NDBUFFERSIZE"])

if Format != None:
print("SETTING FORMAT: " + Format)
Expand Down
21 changes: 17 additions & 4 deletions tools/Python/mcgui/viewclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,15 @@ def showChangeWorkDirDlg(self, lookDir):
if dlg.exec():
return dlg.selectedFiles()[0]

def showStartSimDialog(self, params, comps, mcdisplays, mcplots, formats):
def showStartSimDialog(self, params, comps, mcdisplays, mcplots, formats, buffersize):
if self.__ssd == None:
self.__ssd = McStartSimDialog()
self.__ssd.createParamsWidgets(params)
self.__ssd.set_components(comps)
self.__ssd.set_mcdisplays(mcdisplays)
self.__ssd.set_mcplots(mcplots)
self.__ssd.set_formats(formats)
self.__ssd.set_buffersize(buffersize)
if self.__ssd.exec():
return self.__ssd.getValues()
else:
Expand Down Expand Up @@ -650,6 +651,7 @@ def __init__(self, parent=None):
self._last_mcdisplays = None
self._last_mcplots = None
self._last_formats = None
self._last_buffersize = mccode_config.configuration["NDBUFFERSIZE"]
self.ui = Ui_dlgStartSim()
self.ui.setupUi(self)
if not mccode_config.configuration["PARTICLE"] == "neutron":
Expand Down Expand Up @@ -694,7 +696,10 @@ def set_formats(self, formats):
self.ui.cbxFormats.clear()
for f in formats:
self.ui.cbxFormats.addItem(f)


def set_buffersize(self, buffersize):
self.ui.edtNDbufsiz.setText(buffersize)

def _set_inspect_visible(self, sim_run_idx):
visible = False
if sim_run_idx == 1 or sim_run_idx == 2:
Expand Down Expand Up @@ -725,6 +730,7 @@ def getValues(self):
7 - output directory (str)
8 - autoplotter
9 - format
10 - Monitor_nD buffersize
params[]:
[<par_name>, <value>] pairs
'''
Expand Down Expand Up @@ -787,8 +793,11 @@ def getValues(self):
p9 = idx > 0
if idx > 0:
Format = self._last_formats[idx]

fixed_params =[p0, p1, p2, p3, p4, p5, p6, p7, p8, p9]

# Monitor_nD buffersize
p10 = self.ui.edtNDbufsiz.text()

fixed_params =[p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10]

# get dynamic params
params = []
Expand Down Expand Up @@ -1203,6 +1212,9 @@ def initConfigData(self, args):
self.ui.edtFontSize.setText(mccode_config.configuration["GUIFONTSIZE"])
self.ui.edtFontSize.conf_var = "GUIFONTSIZE"

self.ui.edtNDbufsiz.setText(mccode_config.configuration["NDBUFFERSIZE"])
self.ui.edtNDbufsiz.conf_var = "NDBUFFERSIZE"

self.ui.editor.setText(mccode_config.configuration["EDITOR"])
self.ui.editor.conf_var = "EDITOR"

Expand All @@ -1227,6 +1239,7 @@ def __pullValuesTo_mccode_config(self):
mccode_config.compilation[str(self.ui.edtMPIrun.conf_var)] = str(self.ui.edtMPIrun.text())
mccode_config.compilation[str(self.ui.edtNumNodes.conf_var)] = str(self.ui.edtNumNodes.text())
mccode_config.configuration[str(self.ui.edtNumCols.conf_var)] = str(self.ui.edtNumCols.text())
mccode_config.configuration[str(self.ui.edtNDbufsiz.conf_var)] = str(self.ui.edtNDbufsiz.text())
mccode_config.configuration[str(self.ui.edtFontSize.conf_var)] = str(self.ui.edtFontSize.text())
mccode_config.configuration[str(self.ui.editor.conf_var)] = str(self.ui.editor.text())
# Export selected variables to the system / mcrun
Expand Down
26 changes: 23 additions & 3 deletions tools/Python/mcgui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,14 +548,22 @@ def setupUi(self, dlgStartSim):
self.edtRandomSeed.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
self.edtRandomSeed.setObjectName("edtRandomSeed")
self.gridAdvanced.addWidget(self.edtRandomSeed, 0, 1, 1, 1)
self.lblNDbufsiz = QtWidgets.QLabel(self.gbxAdvanced)
self.lblNDbufsiz.setMinimumSize(QtCore.QSize(200, 0))
self.lblNDbufsiz.setObjectName("lblNDbufsiz")
self.gridAdvanced.addWidget(self.lblNDbufsiz, 1, 0, 1, 1)
self.edtNDbufsiz = QtWidgets.QLineEdit(self.gbxAdvanced)
self.edtNDbufsiz.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
self.edtNDbufsiz.setObjectName("edtNDbufsiz")
self.gridAdvanced.addWidget(self.edtNDbufsiz, 1, 1, 1, 1)
self.lblGravity = QtWidgets.QLabel(self.gbxAdvanced)
self.lblGravity.setObjectName("lblGravity")
self.gridAdvanced.addWidget(self.lblGravity, 1, 0, 1, 1)
self.gridAdvanced.addWidget(self.lblGravity, 2, 0, 1, 1)
self.cbxGravity = QtWidgets.QComboBox(self.gbxAdvanced)
self.cbxGravity.setObjectName("cbxGravity")
self.cbxGravity.addItem("")
self.cbxGravity.addItem("")
self.gridAdvanced.addWidget(self.cbxGravity, 1, 1, 1, 1)
self.gridAdvanced.addWidget(self.cbxGravity, 2, 1, 1, 1)
self.verticalLayout_4.addLayout(self.gridAdvanced)
self.verticalLayout_5.addWidget(self.gbxAdvanced)
spacerItem = QtWidgets.QSpacerItem(20, 73, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
Expand Down Expand Up @@ -584,7 +592,8 @@ def setupUi(self, dlgStartSim):
dlgStartSim.setTabOrder(self.edtSteps, self.cbxClustering)
dlgStartSim.setTabOrder(self.cbxClustering, self.edtNodes)
dlgStartSim.setTabOrder(self.edtNodes, self.edtRandomSeed)
dlgStartSim.setTabOrder(self.edtRandomSeed, self.cbxGravity)
dlgStartSim.setTabOrder(self.edtRandomSeed, self.edtNDbufsiz)
dlgStartSim.setTabOrder(self.edtNDbufsiz, self.cbxGravity)
dlgStartSim.setTabOrder(self.cbxGravity, self.btnCancel)
dlgStartSim.setTabOrder(self.btnCancel, self.btnStart)

Expand Down Expand Up @@ -621,6 +630,7 @@ def retranslateUi(self, dlgStartSim):
self.lblMcdisplays.setText(_translate("dlgStartSim", "McDisplay"))
self.gbxAdvanced.setTitle(_translate("dlgStartSim", "Advanced"))
self.lblRandomSeed.setText(_translate("dlgStartSim", "Random seed:"))
self.lblNDbufsiz.setText(_translate("dlgStartSim", "Monitor_nD buffersize:"))
self.lblGravity.setText(_translate("dlgStartSim", "Gravity:"))
self.cbxGravity.setItemText(0, _translate("dlgStartSim", "Off"))
self.cbxGravity.setItemText(1, _translate("dlgStartSim", "On"))
Expand Down Expand Up @@ -929,6 +939,15 @@ def setupUi(self, dlgConfig):
self.lbleditor.setObjectName("lbleditor")
self.gridFlags.addWidget(self.lbleditor, 16, 0, 1, 1)
self.gridFlags.addWidget(self.editor, 17, 0, 1, 1)

self.edtNDbufsiz = QtWidgets.QLineEdit(dlgConfig)
self.edtNDbufsiz.setObjectName("edtNDbufsiz")
self.lblNDbufsiz = QtWidgets.QLabel(dlgConfig)
self.lblNDbufsiz.setObjectName("lblNDbufsiz")
self.gridFlags.addWidget(self.lblNDbufsiz, 18, 0, 1, 1)
self.gridFlags.addWidget(self.edtNDbufsiz, 19, 0, 1, 1)


self.verticalLayout.addLayout(self.gridFlags)
self.hlayoutButtons = QtWidgets.QHBoxLayout()
self.hlayoutButtons.setObjectName("hlayoutButtons")
Expand Down Expand Up @@ -976,6 +995,7 @@ def retranslateUi(self, dlgConfig):
self.lblNumocols.setText(_translate("dlgConfig", "# parameter columns in run dialogue"))
self.lblFontSize.setText(_translate("dlgConfig", "GUI fontsize"))
self.lbleditor.setText(_translate("dlgConfig", "Choice of external editor"))
self.lblNDbufsiz.setText(_translate("dlgConfig","Monitor_nD buffersize"))
self.btnOk.setToolTip(_translate("dlgConfig", "Keep for this session"))
self.btnOk.setText(_translate("dlgConfig", "Ok"))
self.btnSave.setToolTip(_translate("dlgConfig", "Keep & save configuration to disk"))
Expand Down
4 changes: 2 additions & 2 deletions tools/Python/mcrun/mcrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ def is_valid(path):
'(format list obtained from <instr>.%s -h)' % mccode_config.platform["EXESUFFIX"])

add('--bufsiz',
metavar='BUFSIZ', default='',
help='Monitor_nD list/buffer-size (defaults to 1000000)')
metavar='BUFSIZ', default=mccode_config.configuration["NDBUFFERSIZE"],
help='Monitor_nD list/buffer-size (defaults to '+mccode_config.configuration["NDBUFFERSIZE"]+')')

add('--vecsize',
metavar='VECSIZE', default='',
Expand Down

0 comments on commit ab7456e

Please sign in to comment.