Closed nicrie closed 1 year ago
Oh wow, sorry about that! For whatever reason, I guess DataTree.to_zarr() has a default of mode="w"
which will indeed overwrite the directory contents if it already exists. Dataset.to_zarr() has the much more sensible mode="w-"
as default. This is in general a bit of a gotcha of xarray zarr writes (very easy to rm -rf
a directory if you use mode="w"
).
I can fix this in just a few minutes.
Yes, I just noticed that too. The default value chosen by xarray-datatree seems to me to be quite recklessly chosen. ;)
The default value chosen by xarray-datatree seems to me to be quite recklessly chosen. ;)
Very much so! I will propose this change there as well.
Very much so! I will propose this change there as well.
I already did, hoping to spare some other poor soul the feeling of digital Armageddon. Thanks for fixing this so quickly!
accidental deletions are no fun, hopefully it wasn't anything too catastrophic :fearful:
I was in my "playground" folder. Lost a couple of files but nothing too important + there's a backup. Phew!
Describe the bug When specifying a directory instead of a file path to save a model, the function erroneously overwrites all data within the given directory. This behavior is not only unexpected but also extremely risky—I've just inadvertently lost files this way.
Reproducible Minimal Working Example
Expected behavior No data is overwritten.
Desktop (please complete the following information):
xeofs
version: 2.0.0I think that requires a quick fix @slevang. I will start working on a patch but please take extra caution when utilizing the save function in the meantime.