grass.pygrass: GridModule clean up temporary mapsets when exception occurs#2614
Conversation
When an exception (input raster map does not exist) occurs during the `run()` method of an instance of the `GridModule` class.
wenzeslaus
left a comment
There was a problem hiding this comment.
Thanks for fixing this separately from the other issue. I think the general idea is good, but some changes would make it better - see comments.
I think a test would be doable for the specific bug being fixed. pytest seems like a good choice for that. The "positive" case where everything works is probably easier to test with grass.gunittest. There are some doctest-based tests for GridModule, but I don't know how good they are and there seems to be some confusion between tests of grass.pygrass.modules and grass.pygrass.modules.grid.
Generally, it seems that the resource handling should be more clear. The resource allocation and cleanup should be linked together in a better way, e.g., by having the cleanup set up where the resources are allocated. This may overall improve the class, but for fixing the bug, the current approach in this PR is enough.
wenzeslaus
left a comment
There was a problem hiding this comment.
This is great - short and sweet!
I have two comments, the test actually requires some attention.
Describe the bug
run()method of theGridModuleclass instance doesn't clean up temporary MAPSETs when exception occurs (input raster map doesn't exists).To Reproduce
Steps to reproduce the behavior:
Expected behavior
Clean up the temporary MAPSETs when an exception (input raster map does not exist) occurs during the
run()method of an instance of theGridModuleclass.System description (please complete the following information):