Skip to content

Commit 58662a9

Browse files
committed
Add a config key to allow transfer to a single raw directory
1 parent 82b4177 commit 58662a9

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/murfey/client/watchdir_multigrid.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def stop(self):
4949
self.thread.join()
5050
log.debug("MultigridDirWatcher thread stop completed")
5151

52-
def _handle_metadata(self, directory: Path, extra_directory: str):
52+
def _handle_metadata(self, directory: Path, extra_directory: str, limited=True):
5353
self.notify(
5454
directory,
5555
extra_directory=extra_directory,
5656
analyse=self._analyse,
57-
limited=True,
57+
limited=limited,
5858
tag="metadata",
5959
)
6060
self._seen_dirs.append(directory)
@@ -122,6 +122,12 @@ def _process(self):
122122
/ f"{sample.parent.name}_{sample.name}",
123123
)
124124

125+
elif self._machine_config["single_data_directory"]:
126+
if d.is_dir() and d not in self._seen_dirs:
127+
self._handle_metadata(
128+
d, extra_directory=f"{d.name}", limited=False
129+
)
130+
125131
else:
126132
if d.is_dir() and d not in self._seen_dirs:
127133
self._handle_metadata(

src/murfey/server/api/file_io_instrument.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,16 @@ def suggest_path(
8585
raise FileNotFoundError(log_message)
8686

8787
check_path_name = check_path.name
88-
while check_path.exists():
89-
count = count + 1 if count else 2
90-
check_path = check_path.parent / f"{check_path_name}{count}"
88+
if not machine_config.single_data_directory:
89+
while check_path.exists():
90+
count = count + 1 if count else 2
91+
check_path = check_path.parent / f"{check_path_name}{count}"
9192
if params.touch:
92-
check_path.mkdir()
93+
check_path.mkdir(exist_ok=True)
9394
os.chmod(check_path, mode=machine_config.mkdir_chmod)
9495
if params.extra_directory:
9596
extra_dir = check_path / secure_filename(params.extra_directory)
96-
extra_dir.mkdir()
97+
extra_dir.mkdir(exist_ok=True)
9798
os.chmod(extra_dir, mode=machine_config.mkdir_chmod)
9899
return {"suggested_path": check_path.relative_to(rsync_basepath)}
99100

src/murfey/util/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class MachineConfig(BaseModel): # type: ignore
5050
analyse_created_directories: list[str] = []
5151
gain_reference_directory: Optional[Path] = None
5252
eer_fractionation_file_template: str = ""
53+
single_data_directory: bool = False
5354

5455
# Data transfer setup -------------------------------------------------------------
5556
# General setup

0 commit comments

Comments
 (0)