Recipe
conatus.recipes.recipe.Recipe
dataclass
¶
A recipe.
steps
class-attribute
instance-attribute
¶
steps: list[RuntimeStateStep] = field(default_factory=list)
The steps of the recipe.
actions
class-attribute
instance-attribute
¶
The actions of the recipe.
get_all_imports
¶
Get all the imports of the recipe.
| PARAMETER | DESCRIPTION |
|---|---|
skip_action_imports
|
Whether to skip the imports of the actions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The code of the imports of the recipe, or None if the recipe contains non-retrievable actions. |
Source code in conatus/recipes/recipe.py
replace_terminate
staticmethod
¶
replace_terminate(
line: str, task_definition: TaskDefinition
) -> str
Replace 'terminate(...)' statements with 'return ...' ones.
| PARAMETER | DESCRIPTION |
|---|---|
line
|
The Python statement to modify.
TYPE:
|
task_definition
|
The definition of the task.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The new statement, potentially modified to a return statement. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the assignment in the terminate statement is manifestly incorrect. |
Source code in conatus/recipes/recipe.py
to_code
¶
to_code(
task_definition: TaskDefinition,
*,
skip_action_imports: Literal[True]
) -> str
to_code(
task_definition: TaskDefinition,
*,
skip_action_imports: bool = False
) -> str | None
to_code(
task_definition: TaskDefinition,
*,
skip_action_imports: bool = False
) -> str | None
Convert the recipe to code.
| PARAMETER | DESCRIPTION |
|---|---|
task_definition
|
The definition of the task.
TYPE:
|
skip_action_imports
|
Whether to skip the imports of the actions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The code of the recipe. |