-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
grass.pygrass: Reset back mapset search path after GridModule class instance finish #2567
grass.pygrass: Reset back mapset search path after GridModule class instance finish #2567
Conversation
Commit 55dfaf4 and f28483a handle situation (reset back MAPSET search path and clean temp data) if input map doesn't exists (example bellow basin raster map doesn't exists in the current MAPSET) and Example:
|
With this PR Example: When input map name e.g. elevation has unique name across all LOCATION MAPSETs you could use simple map name as input param e.g.
On the end of |
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 think GridModule should not modify the search path of the current mapset at all. It should simply use fully qualified names if needed.
Sprinkling _reset_mapset_search_path
in the code seems tricky to get right.
try-except with explicit traceback handling seems wrong. Why not finally
or using context manager and with
? But again, no reset would be needed if no modification is done which seems to be the most robust solution.
Yes, I agree with you.
Yes, you're right, thanks. |
Can you please extend the description to comment on what actually changed and what is just indentation? |
@@ -154,8 +154,6 @@ def get_mapset(gisrc_src, gisrc_dst): | |||
copy_special_mapset_files(path_src, path_dst) | |||
src = Mapset(msrc, lsrc, gsrc) | |||
dst = Mapset(mdst, ldst, gdst) | |||
loc = Location() |
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.
Remove extend current MAPSET search path.
visible = [m for m in src.visible] | ||
if src.name not in visible: | ||
visible.append(src.name) | ||
dst.visible.extend(visible) |
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 believe we should keep this. If I interpret this correctly, this is trying to replicate search path of the current mapset in the temporary mapset. So if user doesn't specify input with full name@mapset, this would be needed. At least it doesn't harm, since it's a temp mapset anyway.
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 originally made it so that the user didn't have to specify the exact MAPSET name (full name@MAPSET) when entering the input map name, but then the search path of the current MAPSET needs to be reseted after the run()
method completes.
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 believe we should keep this. If I interpret this correctly, this is trying to replicate search path of the current mapset in the temporary mapset. So if user doesn't specify input with full name@mapset, this would be needed. At least it doesn't harm, since it's a temp mapset anyway.
Example (if these lines are preserved):
- Launch GG with with nc_spm_08_grass7 LOCATION and landsat MAPSET
g.mapsets operation=set mapset=landsat
GRASS nc_spm_08_grass7/landsat:~ > g.mapsets -p
Accessible mapsets:
landsat
- Launch Python script mentioned here
- Check current MAPSET search path again
GRASS nc_spm_08_grass7/landsat:~ > g.mapsets -p
Accessible mapsets:
landsat PERMANENT
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 think the problem is elsewhere, see #2584.
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.
Tested with #2584 and these code lines are preserved (which you mentioned above):
- Check current MAPSET search path again
GRASS nc_spm_08_grass7/landsat:~ > g.mapsets -p
Accessible mapsets:
landsat
Current MAPSET search path is the same as before running GridModule
class instance run()
method.
With these preserved code lines (which you mentioned above) for input map name is still required full name map@MAPSET.
This is mixing a bugfix and enhancement, so it seems to me the CleanManager should be separated into another PR. There have been changes (#2584) and I didn't test recently but it seems only the change in |
8aedae2
to
e88236f
Compare
Yes, you are right. There are two bugs:
|
It looks like the grid.py tests are broken, but I don't see why this change would trigger that. Anyway, the doctest probably needs to be fixed, it shouldn't require SEARCH_PATH. |
I think this is because the SEARCH_PATH file does not exist by default because we removed this line |
…class instance finish (OSGeo#2567) * Fix copy_mapset() func doc test
…class instance finish (OSGeo#2567) * Fix copy_mapset() func doc test
…class instance finish (OSGeo#2567) * Fix copy_mapset() func doc test
…class instance finish (OSGeo#2567) * Fix copy_mapset() func doc test
…class instance finish (OSGeo#2567) * Fix copy_mapset() func doc test
…class instance finish (OSGeo#2567) * Fix copy_mapset() func doc test
Describe the bug
Python pygrass
GridModule
class instance change LOCATION MAPSET search path.To Reproduce
Steps to reproduce the behavior:
g.mapsets operation=set mapset=landsat
g.mapsets -p
Expected behavior
Python pygrass
GridModule
class instance should not change LOCATION MAPSET search path.System description (please complete the following information):
Additional context
GRASS GIS Addons issue OSGeo/grass-addons#787.