wxGUI/gmodeler: Correct variable replacement in model_convert.py#7241
wxGUI/gmodeler: Correct variable replacement in model_convert.py#7241gureckyfrantisek wants to merge 15 commits into
Conversation
|
I realized that the regex now allows for a variable to be parametrized as %{tile.laz or %tile}.laz, which works but could be unwanted behavior. Should I improve the regex based on this realization? |
@gureckyfrantisek Yes, please refine the regex—either adopt curly brace syntax ( |
|
I tested both models (v1: without braces and v2: with braces), see Run model:
Display result:
Convert to Python script and run:
|
|
@gureckyfrantisek Just a note: it would be nice to define the regex for variables in a single place and reuse it across the code to avoid duplication. This isn’t a blocker for this PR, as the duplication already exists in the codebase. |
|
The issue is deeper, running the model now displays the maps correctly, but so should the maps when the Display prop is changed in canvas aswell as the map name after running the converted Python script. I used a very simillar logic for all these cases but only after running the model it is substituted correctly. Running converted Python doesn't fail but also doesn't display the maps and the Display prop in canvas fails. |
I can confirm that the Modeler now displays maps correctly. I also tested running the Modeler from the command line ( Traceback (most recent call last):
File "https://github.com/home/martin/src/grass/dist.x86_64-pc-linux-gnu/gui/wxpython/gmodeler/panels.py", line 427, in OnModelDone
layers = self._giface.GetLayerList().GetLayersByName(data.GetResolvedValue(resolved))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'GetLayersByName'
A Python script (which was converted from a model) is not expected to add any maps to the Display. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
I applied and verified changes from code review, variable replacement now works as expected in my opinion. |
I found the issue which caused the previous variable in the same string not get recognized.
The issue was that when another match was found, the old value got replaced instead of the updated one called "parametrizedValue".
Also made the curly braces around variable names optional, they get recognized correctly but leaving them mandatory should be readable, that is up for debate.
I tested this with r.in.pdal and a *.laz file and the import worked as expected with both the values replaced with options.
This will resolve #7212.