Skip to content

Commit 91dbd1c

Browse files
authored
add --reset-fail-count flag to dpdisp submission (#430)
1 parent e00be5a commit 91dbd1c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

dpdispatcher/dpdisp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ def main_parser() -> argparse.ArgumentParser:
5454
action="store_true",
5555
help="Clean submission.",
5656
)
57+
parser_submission_action.add_argument(
58+
"--reset-fail-count",
59+
action="store_true",
60+
help="Reset fail count of all jobs to zero.",
61+
)
5762
##########################################
5863
# gui
5964
parser_gui = subparsers.add_parser(
@@ -105,6 +110,7 @@ def main():
105110
download_terminated_log=args.download_terminated_log,
106111
download_finished_task=args.download_finished_task,
107112
clean=args.clean,
113+
reset_fail_count=args.reset_fail_count,
108114
)
109115
elif args.command == "gui":
110116
start_dpgui(

dpdispatcher/entrypoints/submission.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def handle_submission(
1212
download_terminated_log: bool = False,
1313
download_finished_task: bool = False,
1414
clean: bool = False,
15+
reset_fail_count: bool = False,
1516
):
1617
"""Handle terminated submission.
1718
@@ -25,13 +26,21 @@ def handle_submission(
2526
Download finished tasks.
2627
clean : bool, optional
2728
Clean submission.
29+
reset_fail_count : bool, optional
30+
Reset fail count of all jobs to zero.
2831
2932
Raises
3033
------
3134
ValueError
3235
At least one action should be specified.
3336
"""
34-
if int(download_terminated_log) + int(download_finished_task) + int(clean) == 0:
37+
if (
38+
int(download_terminated_log)
39+
+ int(download_finished_task)
40+
+ int(clean)
41+
+ int(reset_fail_count)
42+
== 0
43+
):
3544
raise ValueError("At least one action should be specified.")
3645

3746
submission_file = record.get_submission(submission_hash)
@@ -42,7 +51,18 @@ def handle_submission(
4251
# TODO: for unclear reason, the submission_hash may be changed
4352
submission.submission_hash = submission_hash
4453
submission.machine.context.bind_submission(submission)
54+
if reset_fail_count:
55+
for job in submission.belonging_jobs:
56+
job.fail_count = 0
57+
# save to remote and local
58+
submission.submission_to_json()
59+
record.write(submission)
60+
if int(download_terminated_log) + int(download_finished_task) + int(clean) == 0:
61+
# if only reset_fail_count, no need to update submission state (expensive)
62+
return
4563
submission.update_submission_state()
64+
submission.submission_to_json()
65+
record.write(submission)
4666

4767
terminated_tasks = []
4868
finished_tasks = []

0 commit comments

Comments
 (0)