microsoft / aurora

Implementation of the Aurora model for atmospheric forecasting
https://microsoft.github.io/aurora
Other
247 stars 31 forks source link

Batch.save() #46

Closed luiservela closed 1 month ago

luiservela commented 1 month ago

Hi all, I am in need of saving a batch object (class aurora.Batch) to disc so that I can re-use it later/many-times. I currently do not see any methods that can get this done. Are you guys considering working on this feature? If not, what would be -in your opinion- the smartest way to save such an object? Best, LV

wesselb commented 1 month ago

Hey @luiservela!

Perhaps you can use pickle for this:

import pickle

batch = ...

# Save:
with open("batch.pickle", "wb") as f:
    pickle.dump(batch, f, protocol=pickle.HIGHEST_PROTOCOL)

# Load:
with open("batch.pickle", "rb") as f:
    loaded_batch = pickle.load(f)

It would be possible to implement a batch.save("filename") and Batch.load("filename") methods, but perhaps the above suffices.

luiservela commented 1 month ago

Thats perfect for my use case!

Thank you, @wesselb

wesselb commented 1 month ago

Not a problem at all! :)