arviz icon indicating copy to clipboard operation
arviz copied to clipboard

PermissionError when using `arviz.InferenceData.to_netcdf()` to overwrite existing file.

Open mattiasthalen opened this issue 3 years ago • 5 comments

Describe the bug Exits with PermissionError when trying to use arviz.InferenceData.to_netcdf() to overwrite an existing file.

To Reproduce Generate inference data. Export using to_netcdf(). Export again and get error.

Expected behavior Existing file is overwritten.

Additional context Arviz 0.11.2 Google Colaboratory using TPU.

Error message PermissionError: [Errno 13] Permission denied: b'/content/drive/MyDrive/Colab Notebooks/Pyro: RepOne Strength/export/velocity_inference_mcmc.nc

mattiasthalen avatar Jun 25 '21 18:06 mattiasthalen

I wonder if we leave file open?

ahartikainen avatar Jun 25 '21 19:06 ahartikainen

I wonder if we leave file open?

Well, the source shows that the final step, before return, is data.close().

mattiasthalen avatar Jun 25 '21 20:06 mattiasthalen

Hi @mattiasthalen is this still an issue? If you are observing this when saving, then loading and then saving again then you can try setting az.rcParams["data.load"] = "eager"

aloctavodia avatar Jul 19 '21 05:07 aloctavodia

I'm still getting this issue and when I looked for the files in the Windows resource manager, they seemed to still be open. Perhaps net_cdf is not closing the files?

opherdonchin avatar Jul 03 '22 19:07 opherdonchin

For me too.

Edit: permission denied only if inside import pymc as pm; with pm.Model() as model: [...].

Edit2: No, something else is going on. Sometimes it failed, and sometimes it did not...

bonh avatar Mar 03 '23 10:03 bonh