Skip to content
Snippets Groups Projects
Commit 95cc01a3 authored by payno's avatar payno
Browse files

VolumeSingleFrameBase: rename 'ignore_existing_files' to...

VolumeSingleFrameBase: rename 'ignore_existing_files' to 'skip_existing_data_files_removal' and 'clean_output_data' to 'remove_existing_data_files'
parent 8a23bf14
No related branches found
No related tags found
1 merge request!243Fix single frame
......@@ -70,7 +70,7 @@ class VolumeSingleFrameBase(VolumeBase):
)
self._start_index = start_index
self._ignore_existing_files = False
self._skip_existing_data_files_removal = False
@property
def start_index(self) -> int:
......@@ -84,21 +84,21 @@ class VolumeSingleFrameBase(VolumeBase):
return os.path.basename(url.file_path())
@property
def ignore_existing_files(self) -> bool:
def skip_existing_data_files_removal(self) -> bool:
"""The loading of the volume for single frame base is done by loading all the file
contained in a folder data_url.file_path(). When saving the data we make sure there is no 'remaining' of
any previous saving by using the file pattern.
But when we want to save a volume from several thread (one thread save the n first frame, second the n next frame ...) this
could be a limitation.
So in this case we can use the 'ignore_existing_files' that will avoid calling '_clean_output_data'
So in this case we can use the 'ignore_existing_files' that will avoid calling '_remove_existing_data_files'
"""
return self._ignore_existing_files
return self._skip_existing_data_files_removal
@ignore_existing_files.setter
def ignore_existing_files(self, ignore: bool) -> None:
@skip_existing_data_files_removal.setter
def skip_existing_data_files_removal(self, ignore: bool) -> None:
if not isinstance(ignore, bool):
raise TypeError(f"ignore should be a bool. Got {type(ignore)}")
self._ignore_existing_files = ignore
self._skip_existing_data_files_removal = ignore
@docstring(VolumeBase)
def deduce_data_and_metadata_urls(self, url: DataUrl | None) -> tuple:
......@@ -216,7 +216,7 @@ class VolumeSingleFrameBase(VolumeBase):
}
return data_path.format(**keywords)
def clean_output_data(self, url: DataUrl) -> None:
def remove_existing_data_files(self, url: DataUrl) -> None:
"""Clean any existing files (if overwrite and rights) that must be used for saving"""
if not os.path.exists(url.file_path()):
return
......@@ -252,8 +252,8 @@ class VolumeSingleFrameBase(VolumeBase):
"Cannot get data_url. An url should be provided. Don't know where to save this."
)
else:
if not self.ignore_existing_files:
self.clean_output_data(url=url)
if not self.skip_existing_data_files_removal:
self.remove_existing_data_files(url=url)
_logger.info(f"save data to {url.path()}")
# if necessary create output directory (some third part writer does not do it for us)
......
......@@ -217,7 +217,7 @@ def test_several_writer(tmp_path, volume_constructor):
)
volume_2.rescale_data = False
volume_1.save()
volume_2.ignore_existing_files = True
volume_2.skip_existing_data_files_removal = True
volume_2.save()
full_volume = volume_constructor(folder=volume_dir)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment