Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/murfey/client/watchdir_multigrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ 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):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think _handle_subdir might be a suitable replacement name for _handle_metadata, as it seems to be notifying the notifying the subscribed components to create an additional Analyser for the sub-directory stated in extra_directory.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly, as discussed the name is unchanged but a comment has been added

"""
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,
analyse=self._analyse,
limited=True,
limited=limited,
tag="metadata",
)
self._seen_dirs.append(directory)
Expand Down Expand Up @@ -122,6 +128,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(
Expand Down
11 changes: 6 additions & 5 deletions src/murfey/server/api/file_io_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}

Expand Down
1 change: 1 addition & 0 deletions src/murfey/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down