Skip to content

Commit

Permalink
add --reset-fail-count flag to dpdisp submission (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz committed Jan 18, 2024
1 parent e00be5a commit 91dbd1c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dpdispatcher/dpdisp.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def main_parser() -> argparse.ArgumentParser:
action="store_true",
help="Clean submission.",
)
parser_submission_action.add_argument(
"--reset-fail-count",
action="store_true",
help="Reset fail count of all jobs to zero.",
)
##########################################
# gui
parser_gui = subparsers.add_parser(
Expand Down Expand Up @@ -105,6 +110,7 @@ def main():
download_terminated_log=args.download_terminated_log,
download_finished_task=args.download_finished_task,
clean=args.clean,
reset_fail_count=args.reset_fail_count,
)
elif args.command == "gui":
start_dpgui(
Expand Down
22 changes: 21 additions & 1 deletion dpdispatcher/entrypoints/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def handle_submission(
download_terminated_log: bool = False,
download_finished_task: bool = False,
clean: bool = False,
reset_fail_count: bool = False,
):
"""Handle terminated submission.
Expand All @@ -25,13 +26,21 @@ def handle_submission(
Download finished tasks.
clean : bool, optional
Clean submission.
reset_fail_count : bool, optional
Reset fail count of all jobs to zero.
Raises
------
ValueError
At least one action should be specified.
"""
if int(download_terminated_log) + int(download_finished_task) + int(clean) == 0:
if (
int(download_terminated_log)
+ int(download_finished_task)
+ int(clean)
+ int(reset_fail_count)
== 0
):
raise ValueError("At least one action should be specified.")

submission_file = record.get_submission(submission_hash)
Expand All @@ -42,7 +51,18 @@ def handle_submission(
# TODO: for unclear reason, the submission_hash may be changed
submission.submission_hash = submission_hash
submission.machine.context.bind_submission(submission)
if reset_fail_count:
for job in submission.belonging_jobs:
job.fail_count = 0
# save to remote and local
submission.submission_to_json()
record.write(submission)
if int(download_terminated_log) + int(download_finished_task) + int(clean) == 0:
# if only reset_fail_count, no need to update submission state (expensive)
return
submission.update_submission_state()
submission.submission_to_json()
record.write(submission)

terminated_tasks = []
finished_tasks = []
Expand Down

0 comments on commit 91dbd1c

Please sign in to comment.