From 3750ede6e35aad1c9820b9522f02d282eb23c0f7 Mon Sep 17 00:00:00 2001 From: DiamondJoseph <53935796+DiamondJoseph@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:36:41 +0100 Subject: [PATCH] Make FilenameProvider optional on PathProvider impl (#547) * Adjust FilenameProvider signature to match PathProvider --- src/ophyd_async/core/_providers.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ophyd_async/core/_providers.py b/src/ophyd_async/core/_providers.py index a0802c31e4..8fe95bf7c4 100644 --- a/src/ophyd_async/core/_providers.py +++ b/src/ophyd_async/core/_providers.py @@ -26,13 +26,11 @@ class PathInfo: class FilenameProvider(Protocol): @abstractmethod - def __call__(self) -> str: + def __call__(self, device_name: Optional[str] = None) -> str: """Get a filename to use for output data, w/o extension""" class PathProvider(Protocol): - _filename_provider: FilenameProvider - @abstractmethod def __call__(self, device_name: Optional[str] = None) -> PathInfo: """Get the current directory to write files into""" @@ -42,7 +40,7 @@ class StaticFilenameProvider(FilenameProvider): def __init__(self, filename: str): self._static_filename = filename - def __call__(self) -> str: + def __call__(self, device_name: Optional[str] = None) -> str: return self._static_filename @@ -55,7 +53,7 @@ def __init__( self._uuid_call_func = uuid_call_func self._uuid_call_args = uuid_call_args or [] - def __call__(self) -> str: + def __call__(self, device_name: Optional[str] = None) -> str: if ( self._uuid_call_func in [uuid.uuid3, uuid.uuid5] and len(self._uuid_call_args) < 2 @@ -84,7 +82,7 @@ def __init__( self._increment = increment self._inc_delimeter = inc_delimeter - def __call__(self): + def __call__(self, device_name: Optional[str] = None) -> str: if len(str(self._current_value)) > self._max_digits: raise ValueError( f"Auto incrementing filename counter \ @@ -111,7 +109,7 @@ def __init__( self._create_dir_depth = create_dir_depth def __call__(self, device_name: Optional[str] = None) -> PathInfo: - filename = self._filename_provider() + filename = self._filename_provider(device_name) return PathInfo( directory_path=self._directory_path, @@ -146,7 +144,7 @@ def __init__( self._inc_delimeter = inc_delimeter def __call__(self, device_name: Optional[str] = None) -> PathInfo: - filename = self._filename_provider() + filename = self._filename_provider(device_name) padded_counter = f"{self._current_value:0{self._max_digits}}" @@ -199,7 +197,7 @@ def __call__(self, device_name: Optional[str] = None) -> PathInfo: current_date, ) - filename = self._filename_provider() + filename = self._filename_provider(device_name) return PathInfo( directory_path=self._base_directory_path / ymd_dir_path, filename=filename,