Improve management of temporary files#108
Conversation
|
Hi @Kodiologist, thanks for this contribution. Definitely agree that finer control over tempfile handling would be beneficial especially when moving large amounts of data between R and |
No, I did try specifying |
|
Yes, these approaches won't catch everything, for example tempfiles that are generated when data is exported from the GRASS database during Would you mind also creating a test for this that checks that everything is contained in the user-specified |
aa781b9 to
3ad98b2
Compare
I've extended "testing basic doGRASS, execGRASS, stringexecGRASS" for this purpose. I've also polished things up in general, so this PR should be ready to go now. The test named "testing read_RAST using sp" fails for me, but it's already failing on main. My feeling is that an environment variable probably isn't the right way to store this temporary-directory name, but it seemed consistent with how |
|
It may be possible to add |
|
Could you just re-document - otherwise it looks great. Regarding the environment variables, I've been working on an overhaul of the initGRASS process. Making use of |
|
Sure, done. |
|
The safest method to manage rgrass's state would probably be for |
|
Thanks @Kodiologist, all tests pass and the |
I noticed that if an R process uses rgrass a lot, temporary files can really accumulate. In one case, in which I was running
execGRASSandread_RASTin concurrent loops for 15 hours, I had over 7 million files. It's hard to clean these up without nukingtempdir()entirely, because many of the temporary files are created with generic names at the root oftempdir().Here my approach has been to give
initGRASSa new parameter that can be used to set the root of all further temporary files (other than the ones created by GRASS ing.tempfile). I can then delete them withon.exitin my calling code.This PR is incomplete (e.g., I didn't document the new parameter), but I figured I'd submit it as-is to see if you're interested before I polish it up.