Recipe
conatus_core.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 packages/conatus_core/src/conatus_core/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 packages/conatus_core/src/conatus_core/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.
Steps coming from passive actions (see Action.passive
) are omitted: they exist to inform
the model mid-run and have no place in a deterministic replay script.
A passive step is still emitted if one of its return variables is
referenced by another recorded step, since dropping it would break
the generated 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. |
Source code in packages/conatus_core/src/conatus_core/recipes/recipe.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |