Skip to content

Commit

Permalink
Add graveyard project that broken jobs can be moved to for inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrv committed Aug 2, 2024
1 parent da25bfb commit 9b0aa35
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pyiron_contrib/repair/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,9 @@ def register(self, tool, status=None):

def restart(self, job):
new = job.restart()
# avoids problems with restart files if original job is deleted
return new

def fix_job(self, tool, job):
def fix_job(self, tool, job, graveyard=None):
try:
new_job = self.restart(job)
except Exception as e:
Expand Down Expand Up @@ -191,7 +190,10 @@ def fix_job(self, tool, job):
pid = job.parent_id

name = job.name
job.remove()
if graveyard is None:
job.remove()
else:
job.move_to(graveyard)
new_job.rename(name)

new_job.master_id = mid
Expand All @@ -216,13 +218,14 @@ def find_tool(self, job):
logger.warn(f"Matching {tool} on job {job.id} failed with {e}!")
raise NoMatchingTool("Cannot find stuitable tool!")

def fix_project(self, project, server_override={}, refresh=True, **kwargs):
def fix_project(self, project, server_override={}, refresh=True, graveyard=None, **kwargs):
"""
Fix broken jobs.
Args:
project (Project): search this project for broken jobs
server_override (dict): override these values on the restarted jobs
graveyard (Project): move fixed projects here, instead of deleting
**kwargs: pass through project.job_table when searching; use to
restrict what jobs are fixed
"""
Expand Down Expand Up @@ -260,7 +263,7 @@ def fix_project(self, project, server_override={}, refresh=True, **kwargs):
tool = self.find_tool(job)
fixing[type(tool).__name__].append(job.id)
if not tool.fix_inplace(job, self):
job = self.fix_job(tool, job)
job = self.fix_job(tool, job, graveyard=graveyard)
for k, v in server_override.items():
setattr(job.server, k, v)
job.run()
Expand Down

0 comments on commit 9b0aa35

Please sign in to comment.