Bopytex/bopytex/worker/__init__.py

24 lines
568 B
Python
Raw Normal View History

class ActionNotFound(Exception):
pass
class Dispatcher:
def __init__(self, actions: list):
self._actions = actions
def __call__(self, task):
try:
choosen_action = self._actions[task.action]
except KeyError:
raise ActionNotFound(f"The action {task.action} is not in {self._actions.keys()}")
return choosen_action(
args=task.args,
deps=task.deps,
output=task.output
)
def fake_worker(args, deps, output):
yield f"FAKE - {args} - {deps} - {output}"