Feat: manage failing tasks in scheduler
This commit is contained in:
@@ -8,15 +8,16 @@ from bopytex.worker import Dispatcher
|
||||
class Scheduler:
|
||||
"""Scheduler is responsible of getting tasks (the tasks) and yield those that can be done"""
|
||||
|
||||
def __init__(self, dispatcher:Dispatcher, done: list[str] = None):
|
||||
def __init__(self, dispatcher:Dispatcher, output_done: list[str] = None):
|
||||
self._dispatcher = dispatcher
|
||||
|
||||
if done is None:
|
||||
self._done = []
|
||||
if output_done is None:
|
||||
self._output_done = []
|
||||
else:
|
||||
self._done = done
|
||||
self._output_done = output_done
|
||||
|
||||
self._tasks = []
|
||||
self._failed_tasks = []
|
||||
|
||||
@property
|
||||
def tasks(self) -> list[Task]:
|
||||
@@ -29,7 +30,7 @@ class Scheduler:
|
||||
return [
|
||||
task
|
||||
for task in self.tasks
|
||||
if not task.deps or all([d in self.done for d in task.deps])
|
||||
if not task.deps or all([d in self.output_done for d in task.deps])
|
||||
]
|
||||
|
||||
@property
|
||||
@@ -43,8 +44,12 @@ class Scheduler:
|
||||
return {task.output for task in self.tasks}
|
||||
|
||||
@property
|
||||
def done(self) -> list[str]:
|
||||
return self._done
|
||||
def output_done(self) -> list[str]:
|
||||
return self._output_done
|
||||
|
||||
@property
|
||||
def failed_tasks(self) -> list[Task]:
|
||||
return self._failed_tasks
|
||||
|
||||
def append(self, tasks: list[Task]):
|
||||
self._tasks += tasks
|
||||
@@ -60,9 +65,10 @@ class Scheduler:
|
||||
|
||||
self._tasks.remove(task)
|
||||
message = self._dispatcher(task)
|
||||
|
||||
if message.status == 0:
|
||||
self._done.append(task.output)
|
||||
self._output_done.append(task.output)
|
||||
else:
|
||||
self._failed_tasks.append(task)
|
||||
|
||||
return message
|
||||
|
||||
|
Reference in New Issue
Block a user