temporal: Use temporary GISRC env instead of g.mapset for import#7434
temporal: Use temporary GISRC env instead of g.mapset for import#7434saket0187 wants to merge 2 commits into
Conversation
petrasovaa
left a comment
There was a problem hiding this comment.
This looks good! I think it would be good to add a test covering this particular fix, perhaps in t.rast.import. There is already a unittest we could expand.
Hello, I’m a bit confused about how to check the location in the middle of the test. The old code also switched back to the original location at the end, so I’m not sure how to show the difference exactly. Do you have any suggestions? |
I was just thinking to test the project option ('project' used to be called 'location') that it does what it's supposed to do, you don't need to demonstrate the fix itself, that would be indeed complicated (that's what you meant, right?). So just testing the new project exists should be enough, the current test is not testing that at all. I also noticed the project option has description "Do not run this module in parallel or interrupt it when a new project should be created", I assume that can be removed now. |
Yes
While running the test file if __name__ == "__main__":
from grass.gunittest.main import test
test()at the end of the file like the other tests? |
|
Yes, here is the diff to get it working: |
|
Hi @petrasovaa , self.assertModule(
"t.rast.import",
flags="o",
input=self.input_,
output="B",
basename="b",
project=self.new_project_name,
overwrite=True
)However, the test fails at the very end. I tested this against both the old g.mapset code and the new environment code, and it crashes identically on both with this exact error: Here is the AI generated summary of error The error is caused by a core synchronization bug inside the t.rast.import module whenever the project flag is used.
Here is exactly what happens:
- The Success: The module successfully creates the new project, and its background subprocesses correctly extract the raster maps into that new location.
- The Bug: The main Python script's temporal database connection (tgis) gets permanently locked to the original project the moment the script starts up.
- The Crash: At the very end of the script, when Python tries to register the newly extracted maps, it searches the old database cache instead of the new one, fails to find them, and crashes with The map does not exist.
|
This PR tries to address #3132
Replace g.mapset‑based project switching in stds_import.py with a temporary GISRC environment so the user’s session project/mapset does not change during background imports.