Feat: write is_finishable
This commit is contained in:
@@ -1,21 +1,37 @@
|
||||
""" Scheduler for action to make """
|
||||
|
||||
|
||||
from bopytex.planner import Task
|
||||
|
||||
|
||||
class Scheduler:
|
||||
def __init__(self, actions: list):
|
||||
def __init__(self, actions: list, done: list[str] = None):
|
||||
self.actions = actions
|
||||
|
||||
if done is None:
|
||||
self._done = []
|
||||
else:
|
||||
self._done = done
|
||||
|
||||
self._tasks = []
|
||||
self._done = []
|
||||
|
||||
@property
|
||||
def tasks(self):
|
||||
return self._tasks
|
||||
|
||||
@property
|
||||
def all_deps(self):
|
||||
return {d for task in self.tasks for d in task.deps}
|
||||
|
||||
@property
|
||||
def all_output(self):
|
||||
return {task.output for task in self.tasks}
|
||||
|
||||
@property
|
||||
def done(self):
|
||||
return self._done
|
||||
|
||||
def append(self, tasks):
|
||||
def append(self, tasks: list[Task]):
|
||||
self._tasks += tasks
|
||||
|
||||
def dispatch(self, task):
|
||||
@@ -53,3 +69,6 @@ class Scheduler:
|
||||
def run(self):
|
||||
for _ in self:
|
||||
pass
|
||||
|
||||
def is_finishable(self):
|
||||
return self.all_deps.issubset(self.all_output)
|
||||
|
Reference in New Issue
Block a user