Skip to content
Merged
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
12 changes: 6 additions & 6 deletions src/nomadic/realtime/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[
Expand All @@ -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
6 changes: 3 additions & 3 deletions src/nomadic/util/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
29 changes: 15 additions & 14 deletions src/nomadic/util/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading