nqxpack.save#
- nqxpack.save(object, path, *, zip=True)[source]#
Saves an object to a file, using the NQXPack format.
Warning
The file will record the versions of installed packages whose objects are serialized to the file. A compatible version of those libraries will be required to load the file. By ‘compatible’, it is intended a version of libraries that is API-compatible with the version that was used to save the file.
In general, we recomend to use the same version of the libraries that were used to save the file.
The NQXPack format is a zip file that contains the following files:
metadata.json: Contains metadata about the file, including the format version and the versions of the libraries used to save the file.
object.json: A json file, in a format similar to Hydra’s, that contains the information necessary to reconstruct the object.
assets/: A directory containing any object that cannot easily be serialized to json. This will generally contain large objects, like numpy arrays, stored into a binary blob.
Warning
The NQXPack format is in beta not guaranteed to be stable at the moment.
It attempts to be backwards-compatible, but not forwards-compatible. This means that you can load files saved with older versions of NQXPack, but you cannot load files saved with newer versions. An informative error will be thrown in that case. However, the guarantee is, for the time-being, best-effort only.
The NQXPack format is not secure. Do not load files from untrusted sources!
- Parameters:
object – The object to save.
path – The path to save the object to. If the path does not have a .nk extension, it will be added.
zip (
bool) – If True (default), the object will be saved in a zip file. If False, it will be saved in a directory.