From 14776bfd77ac893e44ac08483a056a4d12129729 Mon Sep 17 00:00:00 2001 From: Daniel Bridges Date: Tue, 6 Jan 2026 06:36:30 +0200 Subject: [PATCH 1/4] Append current workspace name if shared_folder is not a workspace --- src/nomadic/realtime/commands.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nomadic/realtime/commands.py b/src/nomadic/realtime/commands.py index 2795206..e6e094d 100644 --- a/src/nomadic/realtime/commands.py +++ b/src/nomadic/realtime/commands.py @@ -17,6 +17,7 @@ from nomadic.util.exceptions import MetadataFormatError from nomadic.util.workspace import ( Workspace, + check_if_workspace_root, looks_like_a_bed_filepath, ) @@ -251,9 +252,12 @@ def find_metadata_file(experiment_name: str, workspace: Workspace) -> str: shared_folder = workspace.get_shared_folder() if shared_folder is not None: + # append current workspace name if shared_folder is not a workspace + if not check_if_workspace_root(Path(shared_folder)): + shared_folder = os.path.join(shared_folder, str(workspace.get_name())) + click.echo(f"Found shared folder ({shared_folder})...") shared_workspace = Workspace(shared_folder) - # Currently not checking if it actually is a workspace, to not require some of the folders that are not needed here files.extend( [ shared_workspace.get_metadata_csv(experiment_name), From f703d6593f5dc122da369da13851eab52ea78e48 Mon Sep 17 00:00:00 2001 From: Bernd Bohmeier Date: Tue, 6 Jan 2026 17:13:39 +0100 Subject: [PATCH 2/4] Fix shared_workspace path The shared workspace path needs to include the name of the workspace --- src/nomadic/realtime/commands.py | 15 ++++++--------- src/nomadic/util/cli.py | 6 +++--- src/nomadic/util/workspace.py | 29 +++++++++++++++-------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/nomadic/realtime/commands.py b/src/nomadic/realtime/commands.py index e6e094d..7ce88fc 100644 --- a/src/nomadic/realtime/commands.py +++ b/src/nomadic/realtime/commands.py @@ -250,14 +250,11 @@ def find_metadata_file(experiment_name: str, workspace: Workspace) -> str: workspace.get_metadata_xlsx(experiment_name), ] - shared_folder = workspace.get_shared_folder() - if shared_folder is not None: - # append current workspace name if shared_folder is not a workspace - if not check_if_workspace_root(Path(shared_folder)): - shared_folder = os.path.join(shared_folder, str(workspace.get_name())) + shared_workspace = workspace.get_shared_workspace() + if shared_workspace is not None: + click.echo(f"Found shared workspace ({shared_workspace})...") - click.echo(f"Found shared folder ({shared_folder})...") - shared_workspace = Workspace(shared_folder) + shared_workspace = Workspace(shared_workspace) files.extend( [ shared_workspace.get_metadata_csv(experiment_name), @@ -272,8 +269,8 @@ def find_metadata_file(experiment_name: str, workspace: Workspace) -> str: if metadata_path is None or not os.path.isfile(metadata_path): msg = f"Metadata file not found. Did you create your metadata file in `{workspace.get_metadata_dir()}`" - if shared_folder: - msg += f", or in `{shared_folder}`" + if shared_workspace: + msg += f", or in `{shared_workspace}`" msg += f", and does the name match `{experiment_name}`?" raise click.BadParameter(message=msg) return metadata_path diff --git a/src/nomadic/util/cli.py b/src/nomadic/util/cli.py index da57032..3e40b12 100644 --- a/src/nomadic/util/cli.py +++ b/src/nomadic/util/cli.py @@ -76,10 +76,10 @@ def complete_experiment_name(ctx: click.Context, param, incomplete): experiments = [] if os.path.exists(metadata_path): experiments.extend(list_experiment_names(metadata_path)) - shared_folder = workspace.get_shared_folder() - if shared_folder: + shared_workspace = workspace.get_shared_workspace() + if shared_workspace: shared_metadata_path = os.path.join( - shared_folder, Workspace(shared_folder).get_metadata_dir() + shared_workspace, Workspace(shared_workspace).get_metadata_dir() ) if os.path.exists(shared_metadata_path): experiments.extend(list_experiment_names(shared_metadata_path)) diff --git a/src/nomadic/util/workspace.py b/src/nomadic/util/workspace.py index 5683380..2898f7d 100644 --- a/src/nomadic/util/workspace.py +++ b/src/nomadic/util/workspace.py @@ -139,22 +139,23 @@ def get_experiment_names(self): if os.path.isdir(os.path.join(self.get_results_dir(), name)) ] - def get_shared_folder(self) -> str | None: + def get_shared_workspace(self) -> str | None: """ - Get the shared folder path from the workspace configuration, if it exists. + Get the shared workspace path from the workspace configuration, if it exists. """ config_path = self.get_config_path() - if os.path.exists(config_path) and os.path.isfile(config_path): - shared_folder = get_config_value( - load_config(config_path), ["share", "defaults", "target_dir"] - ) - else: - shared_folder = None - if ( - shared_folder is not None - and isinstance(shared_folder, str) - and os.path.isdir(shared_folder) - ): - return shared_folder + if not os.path.exists(config_path) or not os.path.isfile(config_path): + return None + + shared_folder = get_config_value( + load_config(config_path), ["share", "defaults", "target_dir"] + ) + + if not isinstance(shared_folder, str) or not os.path.isdir(shared_folder): + return None + + shared_workspace = os.path.join(shared_folder, self.get_name()) + if os.path.isdir(shared_workspace): + return shared_workspace return None From a38bde1dca7d191980f9e05ce8d68dd947494025 Mon Sep 17 00:00:00 2001 From: Bernd Bohmeier Date: Tue, 6 Jan 2026 17:14:46 +0100 Subject: [PATCH 3/4] Fix imports --- src/nomadic/realtime/commands.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nomadic/realtime/commands.py b/src/nomadic/realtime/commands.py index 7ce88fc..d5862bc 100644 --- a/src/nomadic/realtime/commands.py +++ b/src/nomadic/realtime/commands.py @@ -17,7 +17,6 @@ from nomadic.util.exceptions import MetadataFormatError from nomadic.util.workspace import ( Workspace, - check_if_workspace_root, looks_like_a_bed_filepath, ) From 31a8bd55c2a436f1a8edf95ffd1755c27a934ca4 Mon Sep 17 00:00:00 2001 From: Bernd Bohmeier Date: Tue, 6 Jan 2026 17:27:56 +0100 Subject: [PATCH 4/4] Readding deleted comment This comment explains the intent why we are not checking if it is a workspace here. For example before anything was shared this might only contain the metadata folder and that is all we need. --- src/nomadic/realtime/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nomadic/realtime/commands.py b/src/nomadic/realtime/commands.py index d5862bc..858f1d6 100644 --- a/src/nomadic/realtime/commands.py +++ b/src/nomadic/realtime/commands.py @@ -252,8 +252,8 @@ def find_metadata_file(experiment_name: str, workspace: Workspace) -> str: shared_workspace = workspace.get_shared_workspace() if shared_workspace is not None: click.echo(f"Found shared workspace ({shared_workspace})...") - shared_workspace = Workspace(shared_workspace) + # Currently not checking if it actually is a workspace, to not require some of the folders that are not needed here files.extend( [ shared_workspace.get_metadata_csv(experiment_name),