23 lines
513 B
Python
23 lines
513 B
Python
import json
|
|
|
|
import dramatiq
|
|
|
|
from jeeves.db.models import Run, Result
|
|
|
|
|
|
@dramatiq.actor
|
|
def start_execution(execution_id):
|
|
run = Run.objects.get(pk=execution_id)
|
|
result = Result()
|
|
for task in run.flow.tasks:
|
|
flow_step = task.run()
|
|
result.add_step(flow_step)
|
|
run.output += flow_step.output
|
|
if flow_step.error:
|
|
run.success = False
|
|
break
|
|
run._result = json.dumps(result.serialize())
|
|
run.status = Run.FINISHED
|
|
run.save()
|
|
return run
|