Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cli #6

Merged
merged 7 commits into from
Feb 1, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add shared directory check and config override
  • Loading branch information
MathieuMoalic committed Feb 1, 2024
commit b5e5379cd1944089c8285bda19706f326d8b7df1
50 changes: 44 additions & 6 deletions cli/amuman_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ def sanitize_path(path, shared_dir_path):
)


def warning_if_not_mounted(shared_dir_path):
shared_dir_path = Path(shared_dir_path).resolve()
with open("/proc/mounts", "r") as mounts:
for line in mounts:
mount_point = Path(
line.split()[1]
).resolve() # Get the mount point from each line
if shared_dir_path == mount_point:
return
print(
f"[bold red]Warning: the shared directory `{shared_dir_path}` does not appear to be a network drive. It might not be accessible to the nodes."
)


@app.command()
def queue(
paths: Annotated[
Expand Down Expand Up @@ -127,14 +141,38 @@ def queue(
max=300,
),
] = 1,
manager_url: Annotated[
str,
typer.Option(
"--manager-url",
"-m",
help="Override the manager URL from the configuration.",
),
] = None,
shared_dir_path: Annotated[
Path,
typer.Option(
"--shared-dir-path",
"-s",
help="Override the shared directory path from the configuration.",
exists=True,
file_okay=False,
dir_okay=True,
writable=False,
readable=True,
resolve_path=True,
),
] = None,
):
if config_path.is_file():
config = read_config(config_path)
else:
config = init_config(config_path)
manager_url = config["manager_url"]
shared_dir_path = config["shared_dir_path"]
if None in [shared_dir_path, manager_url]:
if config_path.is_file():
config = read_config(config_path)
else:
config = init_config(config_path)
manager_url = config["manager_url"]
shared_dir_path = config["shared_dir_path"]

warning_if_not_mounted(shared_dir_path)
url = f"{manager_url}/manager/task/add_task/"
print(f"[bold green]Submitting jobs to {manager_url}/manager/task/")
for path in track(paths, description="[bold green]Progress:"):
Expand Down