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

Allow hooking job failure for generic error handling #205

Merged
merged 7 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
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
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
Loading