Skip to content

Commit

Permalink
Allow hooking job failure for generic error handling (#205)
Browse files Browse the repository at this point in the history
Allow hooking job failure for generic error handling
  • Loading branch information
NeoLegends authored Sep 23, 2024
2 parents da7f29c + 01a7ca3 commit c7de85e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sisyphus/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ def worker_wrapper(job, task_name, call):
return call


def on_job_failure(job):
"""
Job failure hook.
Can be used for generic job-independent error monitoring, handling or retry
logic.
Sispyhus will call this function w/ the job instance for any failed job.
The callback itself is then responsible for any retry logic, realized by e.g.
analyzing the job log file and removing error files in the job directory as
needed.
The callback needs to be stateless and indempotent, as it can be called multiple
times on the same job, especially if the job remains in the error state after the
callback has finished.
Do:
- use with caution
- ensure you don't build infinite retry loops
- limit to specific use cases (e.g. local disk full, GPU broken, etc.)
"""
pass


def update_engine_rqmt(last_rqmt: Dict, last_usage: Dict):
"""Update requirements after a job got interrupted, double limits if needed
Expand Down
3 changes: 3 additions & 0 deletions sisyphus/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ def run(self):
self.resume_jobs()
self.run_jobs()

for job in self.jobs.get(gs.STATE_ERROR, []):
gs.on_job_failure(job)

# Stop config reader
config_manager.cancel_all_reader()

Expand Down

0 comments on commit c7de85e

Please sign in to comment.