Skip to content

Commit

Permalink
add async saving of sme files
Browse files Browse the repository at this point in the history
  • Loading branch information
AWehrhahn committed Jul 8, 2021
1 parent 0bcf6fc commit 8047c18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/pysme/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def from_flex(ff, sme):
return sme


def save(filename, sme, format="flex"):
def save(filename, sme, format="flex", _async=False):
"""
Create a folder structure inside a tarfile
See flex-format for details
Expand All @@ -73,7 +73,10 @@ def save(filename, sme, format="flex"):
filename = filename + file_ending

if format == "flex":
ff.write(filename)
if _async:
ff.write_async(filename)
else:
ff.write(filename)
elif format == "fits":
ff.to_fits(filename, overwrite=True)
elif format == "json":
Expand Down
4 changes: 2 additions & 2 deletions src/pysme/sme.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def citation(self, output="string"):

return self.create_citation(citation, output=output)

def save(self, filename, format="flex"):
def save(self, filename, format="flex", _async=False):
"""Save the whole SME structure to disk.
The file format is zip file, with one info.json
Expand All @@ -711,7 +711,7 @@ def save(self, filename, format="flex"):
compressed : bool, optional
whether to compress the output, by default False
"""
persistence.save(filename, self, format=format)
persistence.save(filename, self, format=format, _async=_async)

@staticmethod
def load(filename):
Expand Down

0 comments on commit 8047c18

Please sign in to comment.