-
-
Notifications
You must be signed in to change notification settings - Fork 326
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: Export variables to Python in Graphical Modeler #3702
wxGUI: Export variables to Python in Graphical Modeler #3702
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I define a variable without description, the script generation fails with the following error message:
Traceback (most recent call last):
File "/home/ondrej/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/panels.py", line 268, in OnPageChanged
self.pythonPanel.RefreshScript()
File "/home/ondrej/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/panels.py", line 1724, in RefreshScript
self.write_object(
File "/home/ondrej/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/model.py", line 3333, in __init__
self._writePython()
File "/home/ondrej/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/model.py", line 3464, in _writePython
description=vdesc["description"],
~~~~~^^^^^^^^^^^^^^^
KeyError: 'description'
Right, a variable description is optional in the current implementation (see the Now (834a8cc) it's exported as: ...
# % key: fill
# % description:
# % required: yes
... When running exported Python script, the parser complains about missing description:
|
In e2ac8e7, options are formatted only if necessary: run_command("r.in.pdal",
flags="eo",
overwrite=True,
input=f"{options['path']}/dmr5g/{options['tile']}.laz",
output=f"{options['tile']}_dmr",
method="mean",
type="FCELL",
zscale=1.0,
iscale=1.0,
resolution=options["resolution"],
dimension="z") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to create a simple model with only v.buffer
, using variable o
for output
. It crashes with the following error:
Traceback (most recent call last):
File "/home/pesek/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/panels.py", line 1860, in OnRefresh
if self.RefreshScript():
File "/home/pesek/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/panels.py", line 1724, in RefreshScript
self.write_object(
File "/home/pesek/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/model.py", line 3333, in __init__
self._writePython()
File "/home/pesek/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/model.py", line 3526, in _writePython
self._writeItem(item, variables=modelParams)
File "/home/pesek/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/model.py", line 2657, in _writeItem
self._writePythonAction(
File "/home/pesek/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/model.py", line 3566, in _writePythonAction
strcmd + self._getPythonActionCmd(item, task, len(strcmd), variables) + "\n"
File "/home/pesek/workspace/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/model.py", line 3606, in _getPythonActionCmd
found = pattern.search(value)
TypeError: expected string or bytes-like object
The model is simple, but still, attached here. Sorry for the txt
extension, it's because github doesn't support attaching *.gxm
files. It's just mimikry.
model.txt
Thanks for testing! The error is caused by when pyGRASS API (option with multiple values provided a list) is used. Fixed by 8468739. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything seems to work now. Thanks!
Steps to reproduce
Sample model: 06_grass_chm_v3.zip
Current behaviour
No variables exported (as UI options). On the other hand variables are used in command statements (see last row in example below):
New behaviour
Variables exported as UI options and used in the Python code correctly: