diff --git a/src/nomadic/realtime/commands.py b/src/nomadic/realtime/commands.py index 2795206..858f1d6 100644 --- a/src/nomadic/realtime/commands.py +++ b/src/nomadic/realtime/commands.py @@ -249,10 +249,10 @@ 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: - click.echo(f"Found shared folder ({shared_folder})...") - shared_workspace = Workspace(shared_folder) + 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( [ @@ -268,8 +268,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