PyBaMM icon indicating copy to clipboard operation
PyBaMM copied to clipboard

Use `tempfile` for temporary JSON files.

Open prady0t opened this issue 1 year ago • 3 comments

After merging #4125 , we generate a lot of temporary JSON files while running tests. These files are short-lived and are created and deleted with every test passing, although if the tests fail these files have to be deleted manually.

You can see the number of json files being generated when test suit fails many times :

Screenshot 2024-06-18 at 6 27 55 PM

We can use tempfile to generate temporary files to fix this. See : https://docs.python.org/3/library/tempfile.html

prady0t avatar Jun 23 '24 18:06 prady0t

You can assign this to me, I will open a PR soon.

prady0t avatar Jun 23 '24 18:06 prady0t

This is true for notebooks as well. They make images and other files, but do not clean them up

kratman avatar Jun 24 '24 14:06 kratman

For the notebooks, I think it's better to not use tempfiles so as to not mislead newcomers to PyBaMM and Python, plus users might want to inspect the images after the notebook/cell has been executed

agriyakhetarpal avatar Jun 24 '24 15:06 agriyakhetarpal