arviz-devs / arviz

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

Add `InferenceData.close` method #2337

Closed lucianopaz closed 3 months ago

lucianopaz commented 3 months ago

Tell us about it

When an InferenceData object is read from a file, xarray will try to lazily load the underlying Dataset objects keeping an open connection to the underlying file in disk. xarray.Dataset provide the close method to release any resources attached to the open dataset, but arviz does not have something like that for InferenceData objects. That makes it quite complicated to actually release resources if one might need to overwrite the contents of the file that was originally read from disk.