arviz-devs / arviz

Exploratory analysis of Bayesian models with Python
https://python.arviz.org
Apache License 2.0
1.58k stars 394 forks source link

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

Open mattiasthalen opened 3 years ago

mattiasthalen commented 3 years ago

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

ahartikainen commented 3 years ago

I wonder if we leave file open?

mattiasthalen commented 3 years ago

I wonder if we leave file open?

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

aloctavodia commented 3 years ago

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"

opherdonchin commented 2 years ago

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?

bonh commented 1 year ago

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...