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

wxGUI/preferences: allow the user set maximum memory to be used by modules #3307

Merged
Merged
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
77 changes: 77 additions & 0 deletions gui/wxpython/gui_core/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,33 @@ def OnSave(self, event):
group="language", key="locale", subkey="lc_all", value=None
)
lang = None
env = grass.gisenv()
nprocs_gisenv = "NPROCS"
memorydb_gisenv = "MEMORYMB"
# Set gisenv MEMORYMB var value
memorymb = self.memorymb.GetValue()
if memorymb:
grass.run_command(
"g.gisenv",
set=f"{memorydb_gisenv}={memorymb}",
)
elif env.get(memorydb_gisenv):
grass.run_command(
"g.gisenv",
unset=memorydb_gisenv,
)
# Set gisenv NPROCS var value
nprocs = self.nprocs.GetValue()
if nprocs:
grass.run_command(
"g.gisenv",
set=f"{nprocs_gisenv}={nprocs}",
)
elif env.get(nprocs_gisenv):
grass.run_command(
"g.gisenv",
unset=nprocs_gisenv,
)
self.settings.SaveToFile()
Debug.msg(1, "Settings saved to file '%s'" % self.settings.filePath)
self.settingsChanged.emit()
Expand Down Expand Up @@ -1245,6 +1272,56 @@ def _createCmdPage(self, notebook):

gridSizer.Add(verbosity, pos=(row, 1), flag=wx.ALIGN_RIGHT)

row += 1
# nprocs
gridSizer.Add(
StaticText(
parent=panel,
id=wx.ID_ANY,
label=_(
"Number of threads for parallel computing (supported tools only):"
),
),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
pos=(row, 0),
)
self.nprocs = TextCtrl(
parent=panel,
id=wx.ID_ANY,
value=grass.gisenv().get("NPROCS", ""),
validator=IntegerValidator(),
name="NumberOfProcs",
)
gridSizer.Add(
self.nprocs,
flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
pos=(row, 1),
)

row += 1
# memorymb
gridSizer.Add(
StaticText(
parent=panel,
id=wx.ID_ANY,
label=_("Maximum memory in MB to be used (supported tools only):"),
),
flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
pos=(row, 0),
)
self.memorymb = TextCtrl(
parent=panel,
id=wx.ID_ANY,
value=grass.gisenv().get("MEMORYMB", ""),
validator=IntegerValidator(),
name="MemorySizeMB",
)
gridSizer.Add(
self.memorymb,
flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
pos=(row, 1),
)

gridSizer.AddGrowableCol(0)
sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
Expand Down
Loading