save#, container=None, tag=None, filename=None, overwrite=False)[source]#

Save Syncopy data object to disk

The underlying array data object is stored in a HDF5 file, the metadata in a JSON file. Both can be placed inside a Syncopy container, which is a regular directory with the extension ‘.spy’.

  • out (Syncopy data object) – Object to be stored on disk.

  • container (str) – Path to Syncopy container folder (*.spy) to be used for saving. If omitted, the extension ‘.spy’ will be added to the folder name.

  • tag (str) – Tag to be appended to container basename

  • filename (str) – Explicit path to data file. This is only necessary if the data should not be part of a container folder. An extension (*.<dataclass>) is added if omitted. The tag argument is ignored.

  • overwrite (bool) – If True an existing HDF5 file and its accompanying JSON file is overwritten (without prompt).



Return type:



Syncopy objects may also be saved using the class method .save that acts as a wrapper for, e.g.,

>>> save(obj, container="new_spy_container")

is equivalent to


However, once a Syncopy object has been saved, the class method .save can be used as a shortcut to quick-save recent changes, e.g.,


writes the current state of obj to the data/meta-data files on-disk associated with obj (overwriting both in the process). Similarly,


saves obj in the current container ‘new_spy_container’ under a different tag.


Save the Syncopy data object obj on disk in the current working directory without creating a spy-container

>>>, filename="session1")
>>> # --> os.getcwd()/session1.<dataclass>
>>> # --> os.getcwd()/session1.<dataclass>.info

Save obj without creating a spy-container using an absolute path

>>>, filename="/tmp/session1")
>>> # --> /tmp/session1.<dataclass>
>>> # --> /tmp/session1.<dataclass>.info

Save obj in a new spy-container created in the current working directory

>>>, container="container.spy")
>>> # --> os.getcwd()/container.spy/container.<dataclass>
>>> # --> os.getcwd()/container.spy/container.<dataclass>.info

Save obj in a new spy-container created by providing an absolute path

>>>, container="/tmp/container.spy")
>>> # --> /tmp/container.spy/container.<dataclass>
>>> # --> /tmp/container.spy/container.<dataclass>.info

Save obj in a new (or existing) spy-container under a different tag

>>>, container="session1.spy", tag="someTag")
>>> # --> os.getcwd()/session1.spy/session1_someTag.<dataclass>
>>> # --> os.getcwd()/session1.spy/session1_someTag.<dataclass>.info

See also


load data created with