From 06789592a225002422409b10e5872c3f9c0ba01e Mon Sep 17 00:00:00 2001 From: Martin van der Schelling <61459087+mpvanderschelling@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:11:55 +0200 Subject: [PATCH] Remove old files and rename files with correct extensions --- src/f3dasm/_src/design/domain.py | 3 +++ src/f3dasm/_src/experimentdata/_data.py | 3 +++ src/f3dasm/_src/experimentdata/_jobqueue.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/f3dasm/_src/design/domain.py b/src/f3dasm/_src/design/domain.py index 930a36be..29c36b96 100644 --- a/src/f3dasm/_src/design/domain.py +++ b/src/f3dasm/_src/design/domain.py @@ -279,6 +279,9 @@ def store(self, filename: Path) -> None: with open(filename.with_suffix('.tmp'), 'wb') as f: pickle.dump(self, f) + # remove old file if it exists + filename.with_suffix('.pkl').unlink(missing_ok=True) + # rename the file to the correct extension filename.with_suffix('.tmp').rename(filename.with_suffix('.pkl')) diff --git a/src/f3dasm/_src/experimentdata/_data.py b/src/f3dasm/_src/experimentdata/_data.py index 849326f9..1a17448b 100644 --- a/src/f3dasm/_src/experimentdata/_data.py +++ b/src/f3dasm/_src/experimentdata/_data.py @@ -266,6 +266,9 @@ def store(self, filename: Path) -> None: # TODO: The column information is not saved in the .csv! self.to_dataframe().to_csv(filename.with_suffix('.tmp')) + # remove the old file if it exists + filename.with_suffix('.csv').unlink(missing_ok=True) + # rename the file to the correct extension filename.with_suffix('.tmp').rename(filename.with_suffix('.csv')) diff --git a/src/f3dasm/_src/experimentdata/_jobqueue.py b/src/f3dasm/_src/experimentdata/_jobqueue.py index 2f83cefe..34818226 100644 --- a/src/f3dasm/_src/experimentdata/_jobqueue.py +++ b/src/f3dasm/_src/experimentdata/_jobqueue.py @@ -199,6 +199,9 @@ def store(self, filename: Path) -> None: """ self.jobs.to_pickle(filename.with_suffix('.tmp')) + # remove old file if it exists + filename.with_suffix('.pkl').unlink(missing_ok=True) + # rename the file to the correct extension filename.with_suffix('.tmp').rename(filename.with_suffix('.pkl'))