html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/2029#issuecomment-451731920,https://api.github.com/repos/pydata/xarray/issues/2029,451731920,MDEyOklzc3VlQ29tbWVudDQ1MTczMTkyMA==,8419157,2019-01-06T10:46:39Z,2019-01-06T10:46:39Z,NONE,"I assumed that using a `with` statement I have loaded the data into memory and closing the file. ``` with xr.open_dataset(path) as ds: data = ds ``` However this does not load into memory entirely and so lazy loading is still in effect. So using `.load` does what I wanted ``` with xr.open_dataset(path) as ds: data = ds.load() ```","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,309949357 https://github.com/pydata/xarray/issues/2029#issuecomment-377728367,https://api.github.com/repos/pydata/xarray/issues/2029,377728367,MDEyOklzc3VlQ29tbWVudDM3NzcyODM2Nw==,1217238,2018-03-31T22:37:06Z,2018-03-31T22:37:06Z,MEMBER,"That's right, xarray will never modify a file on disk unless you use to_netcdf(). ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,309949357 https://github.com/pydata/xarray/issues/2029#issuecomment-377728037,https://api.github.com/repos/pydata/xarray/issues/2029,377728037,MDEyOklzc3VlQ29tbWVudDM3NzcyODAzNw==,37649,2018-03-31T22:30:50Z,2018-03-31T22:30:50Z,NONE,"Thanks @shoyer! Question: I'd wondered if maybe I `open_dataset` a NetCDF file and then modified one of the `data_vars`, maybe xarray would update the file without me doing anything, but that wasn't the case, correct? So only the loading of data is lazy, data modified is modified only in memory? Thanks for the explanation!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,309949357 https://github.com/pydata/xarray/issues/2029#issuecomment-377572708,https://api.github.com/repos/pydata/xarray/issues/2029,377572708,MDEyOklzc3VlQ29tbWVudDM3NzU3MjcwOA==,1217238,2018-03-30T17:10:12Z,2018-03-30T17:10:12Z,MEMBER,"The problem is that xarray is that when you open up a dataset, xarray does lazy loading of the data from the source file. This lazy loading breaks when you override the source file. As a user, the work around is to always load files entirely from disk, e.g., by calling `.load()`, or to not attempt to override existing files. I'm not quite sure how we should improve this, but this does certainly come up with some frequency, especially for new users. A friendlier warning/error would be nice, but I'm not sure how to detect this behavior in general (this information is not currently very accessible). We could potentially always write to temporary files in `to_netcdf()` and then rename in a final step after writing the data. As a bonus, this results in atomic writes on most platforms.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,309949357