Skip to content

Commit f030c2b

Browse files
authored
Reset retry counter when there is progress (#296)
* Job completed_fraction API * write completed_fraction into submit log * Task resumable, retry count reset when there is progress Fix #295
1 parent f2921a3 commit f030c2b

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

sisyphus/engine.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ def submit(self, task):
187187
submit_info = rqmt.copy()
188188
submit_info["engine_info"] = engine_info
189189
submit_info["engine_name"] = engine_name
190+
completed_fraction = task._job.completed_fraction()
191+
assert completed_fraction is None or 0 <= completed_fraction <= 1, f"{task._job} {completed_fraction=!r}"
192+
submit_info["completed_fraction"] = completed_fraction
190193
with open(submit_log, "a") as submit_file:
191194
submit_file.write("%s\n" % str((task_ids, submit_info)))
192195

sisyphus/job.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,12 @@ def info(self):
12191219
"""
12201220
pass
12211221

1222+
def completed_fraction(self) -> Optional[float]:
1223+
"""
1224+
:return: fraction between 0 and 1 or None if not available
1225+
"""
1226+
return None
1227+
12221228
@classmethod
12231229
def hash(cls, parsed_args: Dict[str, Any]) -> str:
12241230
"""

sisyphus/task.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,12 @@ def _get_state_helper(self, engine, task_id=None):
397397
# used to avoid wrongly marking jobs as interrupted do to slow filesystem updates
398398
elif self.running(task_id):
399399
return gs.STATE_RUNNING
400-
history = [] if engine is None else engine.get_submit_history(self)
401-
if history and len(history[task_id]) > gs.MAX_SUBMIT_RETRIES:
400+
history = [] if engine is None else engine.get_submit_history(self)[task_id]
401+
# Filter entries with less progress than the most recent entry.
402+
# https://github.com/rwth-i6/sisyphus/issues/295
403+
completed_fraction = (history[-1].get("completed_fraction") or 0) if history else 0
404+
history = [d for d in history if (d.get("completed_fraction") or 0) >= completed_fraction]
405+
if len(history) > gs.MAX_SUBMIT_RETRIES:
402406
# More then three tries to run this task, something is wrong
403407
return gs.STATE_RETRY_ERROR
404408
else:

0 commit comments

Comments
 (0)