From 58662a957cab0632c4cd29f6d2bddddf6716912b Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Tue, 19 May 2026 11:25:54 +0100 Subject: [PATCH 1/2] Add a config key to allow transfer to a single raw directory --- src/murfey/client/watchdir_multigrid.py | 10 ++++++++-- src/murfey/server/api/file_io_instrument.py | 11 ++++++----- src/murfey/util/config.py | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/murfey/client/watchdir_multigrid.py b/src/murfey/client/watchdir_multigrid.py index c78310bdb..0a43f56cd 100644 --- a/src/murfey/client/watchdir_multigrid.py +++ b/src/murfey/client/watchdir_multigrid.py @@ -49,12 +49,12 @@ def stop(self): self.thread.join() log.debug("MultigridDirWatcher thread stop completed") - def _handle_metadata(self, directory: Path, extra_directory: str): + def _handle_metadata(self, directory: Path, extra_directory: str, limited=True): self.notify( directory, extra_directory=extra_directory, analyse=self._analyse, - limited=True, + limited=limited, tag="metadata", ) self._seen_dirs.append(directory) @@ -122,6 +122,12 @@ def _process(self): / f"{sample.parent.name}_{sample.name}", ) + elif self._machine_config["single_data_directory"]: + if d.is_dir() and d not in self._seen_dirs: + self._handle_metadata( + d, extra_directory=f"{d.name}", limited=False + ) + else: if d.is_dir() and d not in self._seen_dirs: self._handle_metadata( diff --git a/src/murfey/server/api/file_io_instrument.py b/src/murfey/server/api/file_io_instrument.py index 59a2e826c..8091280f2 100644 --- a/src/murfey/server/api/file_io_instrument.py +++ b/src/murfey/server/api/file_io_instrument.py @@ -85,15 +85,16 @@ def suggest_path( raise FileNotFoundError(log_message) check_path_name = check_path.name - while check_path.exists(): - count = count + 1 if count else 2 - check_path = check_path.parent / f"{check_path_name}{count}" + if not machine_config.single_data_directory: + while check_path.exists(): + count = count + 1 if count else 2 + check_path = check_path.parent / f"{check_path_name}{count}" if params.touch: - check_path.mkdir() + check_path.mkdir(exist_ok=True) os.chmod(check_path, mode=machine_config.mkdir_chmod) if params.extra_directory: extra_dir = check_path / secure_filename(params.extra_directory) - extra_dir.mkdir() + extra_dir.mkdir(exist_ok=True) os.chmod(extra_dir, mode=machine_config.mkdir_chmod) return {"suggested_path": check_path.relative_to(rsync_basepath)} diff --git a/src/murfey/util/config.py b/src/murfey/util/config.py index 11e8db570..16643eec3 100644 --- a/src/murfey/util/config.py +++ b/src/murfey/util/config.py @@ -50,6 +50,7 @@ class MachineConfig(BaseModel): # type: ignore analyse_created_directories: list[str] = [] gain_reference_directory: Optional[Path] = None eer_fractionation_file_template: str = "" + single_data_directory: bool = False # Data transfer setup ------------------------------------------------------------- # General setup From 61178321c4d9f3beb35c263a1648ce759ddcc88a Mon Sep 17 00:00:00 2001 From: yxd92326 Date: Tue, 19 May 2026 12:13:53 +0100 Subject: [PATCH 2/2] Comment on the use of the handle_metadata function --- src/murfey/client/watchdir_multigrid.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/murfey/client/watchdir_multigrid.py b/src/murfey/client/watchdir_multigrid.py index 0a43f56cd..611480e80 100644 --- a/src/murfey/client/watchdir_multigrid.py +++ b/src/murfey/client/watchdir_multigrid.py @@ -50,6 +50,12 @@ def stop(self): log.debug("MultigridDirWatcher thread stop completed") def _handle_metadata(self, directory: Path, extra_directory: str, limited=True): + """ + Handles all unknown directories in the visit folder + These are transferred into a raw folder as subdirectories + named using "extra_directory" + For SPA and Tomo this is metadata, for SXT this will be both metadata and data + """ self.notify( directory, extra_directory=extra_directory,