fmartingr
/
jeeves
Archived
1
0
Fork 0
This repository has been archived on 2021-02-14. You can view files and clone it, but cannot push or open issues or pull requests.
jeeves/jeeves/core/objects.py

51 lines
1.0 KiB
Python

from typing import Any, Dict, List, Text, Optional
from dataclasses import field
from pydantic import BaseModel
from jeeves.core.registry import ActionRegistry
class BaseObject(BaseModel):
pass
class Result(BaseObject):
output: Text = ""
success: bool = False
class Task(BaseObject):
name: Text
type: Text
parameters: Dict[Any, Any]
@property
def action(self):
"""
Returns the instanced :any:`jeeves.core.actions.base.Action` defined in ``type`` for this ``Task``.
"""
return ActionRegistry.get_action_cls(self.type)(parameters=self.parameters)
class Flow(BaseObject):
name: Text
tasks: List[Task] = field(default_factory=list)
class ExecutionStep(BaseObject):
task: Task
result: Optional[Result] = None
class Execution(BaseObject):
flow: Flow
steps: List[ExecutionStep]
success: bool = False
@property
def output(self):
for step in self.steps:
if step.result.output:
yield step.result.output