aiida_cusp.utils.single_archive_data module

Extension to AiiDA’s SinglefileData storing the given file as gzip-compressed archive instead of simply storing the file as-is

class aiida_cusp.utils.single_archive_data.SingleArchiveData(file, filename=None, **kwargs)


Data class used to store the contents of a file as gzip compressed archive in its repository


Return the path of the object in the repository.

Basically replicates the procedure in the internal open method without the final call to the open()


Load the file and return a gzip compressed version of the contents

Parameters:filepath (pathlib.Path) – path to the file whose contents will be loaded and compressed using gzip
Returns:a tuple containing the compressed file contents and the file’s name with ‘.gz’ suffix appended
Return type:tuple

Load the node and return either the archive (i.e. compressed) or the file (i.e. the decompressed) contents stored in the node.

Parameters:decompress (bool) – Indicate wether comressed or uncompressed contents are returned
set_file(file, filename=None)

Compress given file and store it to the node’s repository.

This method differs from the original SinglefileData.set_file() method in that it only accepts a filepath. The additional filename argument is only here to make AiiDA happy and is ignored since we only allow file path inputs from which the filename is deduced.

Parameters:file (pathlib.Path) – path to the file whose contents will be compressed and stored to the repository
Raises:ValueError – if the given path does not point to a file
write_file(filepath, decompress=True)

Write the node’s contents to a file

Params filepath:
 path to the output file to which the stored contents will be written
Params decompress:
 write the decompressed or the archive contents to the file