feat: dispatch transmit args to actions
This commit is contained in:
parent
480ced3259
commit
4dbfe7a82c
@ -20,7 +20,7 @@ class Scheduler:
|
||||
|
||||
def dispatch(self, task):
|
||||
""" Do a task """
|
||||
ans = self.actions[task.action](task.deps)
|
||||
ans = self.actions[task.action](task.deps, task.args)
|
||||
return ans
|
||||
|
||||
def __next__(self):
|
||||
|
@ -3,14 +3,15 @@ from bopytex.scheduler import Scheduler
|
||||
|
||||
|
||||
def test_schedule_append():
|
||||
actions = {"DO": lambda _: "done"}
|
||||
actions = {"DO": lambda deps, args: "done"}
|
||||
scheduler = Scheduler(actions)
|
||||
tasks = [Task(action="DO", args={}, deps=[])]
|
||||
scheduler.append(tasks)
|
||||
assert scheduler.tasks == tasks
|
||||
|
||||
|
||||
def test_schedule_dispatch():
|
||||
actions = {"DO": lambda _: "done"}
|
||||
actions = {"DO": lambda deps, args: "done"}
|
||||
scheduler = Scheduler(actions)
|
||||
task = Task(action="DO", args={}, deps=[])
|
||||
result = scheduler.dispatch(task)
|
||||
@ -18,10 +19,20 @@ def test_schedule_dispatch():
|
||||
|
||||
|
||||
def test_schedule_one_task():
|
||||
actions = {"DO": lambda _: "done"}
|
||||
actions = {"DO": lambda deps, args: "done"}
|
||||
scheduler = Scheduler(actions)
|
||||
scheduler.append([Task(action="DO", args={}, deps=[])])
|
||||
result = scheduler.__next__()
|
||||
assert result == "done"
|
||||
assert scheduler.tasks == []
|
||||
assert scheduler.done == ["done"]
|
||||
|
||||
|
||||
def test_schedule_one_task_with_args():
|
||||
actions = {"DO": lambda deps, args: f"{args['task']} done"}
|
||||
scheduler = Scheduler(actions)
|
||||
scheduler.append([Task(action="DO", args={"task": "one"}, deps=[])])
|
||||
result = scheduler.__next__()
|
||||
assert result == "one done"
|
||||
assert scheduler.tasks == []
|
||||
assert scheduler.done == ["one done"]
|
||||
|
Loading…
Reference in New Issue
Block a user