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

Addition of cancellation for multiple directories and globs. #338

Merged
merged 2 commits into from
Feb 23, 2021
Merged
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
38 changes: 32 additions & 6 deletions maestrowf/maestro.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,39 @@ def cancel_study(args):
# Force logging to Warning and above
LOG_UTIL.configure(LFORMAT, log_lvl=3)

if not os.path.isdir(args.directory):
print("Attempted to cancel a path that was not a directory.")
return 1
directory_list = args.directory

Conductor.mark_cancelled(args.directory)
ret_code = 0
to_cancel = []
if directory_list:
for directory in directory_list:
abs_path = os.path.abspath(directory)
if not os.path.isdir(abs_path):
print(
f"Attempted to cancel '{abs_path}' "
"-- study directory not found.")
ret_code = 1
else:
print(f"Study in '{abs_path}' to be cancelled.")
to_cancel.append(abs_path)

if to_cancel:
ok_cancel = input("Are you sure? [y|[n]]: ")
try:
if ok_cancel in ACCEPTED_INPUT:
for directory in to_cancel:
Conductor.mark_cancelled(directory)
except Exception as excpt:
print(f"Error:\n{excpt}")
print("Error in cancellation. Aborting.")
return -1
else:
print("Cancellation aborted.")
else:
print("Path(s) or glob(s) did not resolve to a directory(ies).")
ret_code = 1

return 0
return ret_code


def load_parameter_generator(path, env, kwargs):
Expand Down Expand Up @@ -341,7 +367,7 @@ def setup_argparser():
'cancel',
help="Cancel all running jobs.")
cancel.add_argument(
"directory", type=str,
"directory", type=str, nargs="+",
help="Directory containing a launched study.")
cancel.set_defaults(func=cancel_study)

Expand Down