Commands
Tasks and Commands
CommandExecutionContext
dataclass
Context information available to all commands.
This information is usually specified in delphyne.yaml
project
files, and also locally in @config
blocks. All values have
defaults. All paths are usually expressed relative to a single
workspace root directory, and can be made absolute using the
with_root
method.
Attributes:
Name | Type | Description |
---|---|---|
strategy_dirs |
Sequence[Path]
|
A sequence of directories in which strategy modules can be found. |
modules |
Sequence[str]
|
A sequence of module in which Python object identifiers
can be resolved (module names can feature |
demo_files |
Sequence[Path]
|
A sequence of demonstration files (either including or
excluding the |
prompt_dirs |
Sequence[Path]
|
A sequence of directories in which to look for prompt templates. |
data_dirs |
Sequence[Path]
|
A sequence of directories in which to look for data files. |
cache_root |
Path | None
|
The directory in which to store all request cache subdirectories. |
result_refresh_period |
float | None
|
The period in seconds at which the
current result is computed and communicated to the UI (e.g.,
the period at which the current trace is exported when
running oracular programs). If |
status_refresh_period |
float | None
|
The period in seconds at which the
current status message is communicated to the UI. If |
Local conguration blocks
Demonstration and command files can override some configuration
information from the delphyne.yaml
file by featuring a comment
block such as:
# @config
# modules: ["my_strategy_module"]
# demo_files: ["demo.yaml"]
# @end
The comment block must be placed at the start of the file, possibly after other comments.
Source code in src/delphyne/stdlib/tasks.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 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 |
|
with_root
with_root(root: Path) -> CommandExecutionContext
Make all paths absolute given a path to the workspace root.
Source code in src/delphyne/stdlib/tasks.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
TaskContext
Bases: Protocol
Context object accessible to all tasks for reporting progress and intermediate results.
Source code in src/delphyne/stdlib/tasks.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
run_command
run_command(
command: Command[A, T],
args: A,
ctx: CommandExecutionContext,
dump_statuses: Path | None = None,
dump_result: Path | None = None,
dump_log: Path | None = None,
on_status: Callable[[str], None] | None = None,
add_header: bool = True,
handle_sigint: bool = False,
) -> CommandResult[T | None]
A simple command runner.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command
|
Command[A, T]
|
The command to run. |
required |
args
|
A
|
The arguments to pass to the command. |
required |
ctx
|
CommandExecutionContext
|
The command execution context. |
required |
dump_statuses
|
Path | None
|
A file in which to dump status messages at regular intervals. |
None
|
dump_result
|
Path | None
|
A file in which to dump intermediate and final results, whose content is refreshed at regular intervals. |
None
|
dump_log
|
Path | None
|
A file in which to dump log messages. |
None
|
on_status
|
Callable[[str], None] | None
|
A function to call every time a status message is issued. |
None
|
add_header
|
bool
|
If |
True
|
handle_sigint
|
bool
|
If |
False
|
Non-existing directories are created automatically.
Source code in src/delphyne/stdlib/tasks.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
Standard Commands
run_strategy
run_strategy(
task: TaskContext[CommandResult[RunStrategyResponse]],
exe: CommandExecutionContext,
args: RunStrategyArgs,
)
Command for running an oracular program from a serialized specification.
Source code in src/delphyne/stdlib/commands/run_strategy.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
RunStrategyArgs
dataclass
Arguments for the run_strategy
command that runs an oracular
program.
Attributes:
Name | Type | Description |
---|---|---|
strategy |
str
|
Name of the strategy to run. |
args |
dict[str, object]
|
Arguments to pass to the strategy constructor. |
policy |
str
|
Name of the policy to use. |
policy_args |
dict[str, object]
|
Arguments to pass to the policy constructor. |
num_generated |
int
|
Number of success values to generate. |
budget |
dict[str, float]
|
Budget limit (infinite for unspecified metrics). |
cache_dir |
str | None
|
Subdirectory of the global cache directory to use for
caching, or |
cache_mode |
CacheMode
|
Cache mode to use. |
cache_format |
CacheFormat
|
Cache format to use. |
export_raw_trace |
bool
|
Whether to export the raw execution trace. |
export_log |
bool
|
Whether to export the log messages. |
export_browsable_trace |
bool
|
Whether to export a browsable trace, which can be visualized in the VSCode extension (see delphyne.analysis.feedback.Trace). |
Source code in src/delphyne/stdlib/commands/run_strategy.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
answer_query
answer_query(
task: TaskContext[CommandResult[AnswerQueryResponse]],
exe: CommandExecutionContext,
cmd: AnswerQueryArgs,
)
A command for answering a query. See AnswerQueryArgs
.
Source code in src/delphyne/stdlib/commands/answer_query.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
AnswerQueryArgs
dataclass
Arguments for the answer_query
command.
Attributes:
Name | Type | Description |
---|---|---|
query |
str
|
The name of the query to answer. |
args |
dict[str, object]
|
Arguments for the query, as a dictionary of JSON values. |
prompt_only |
bool
|
If |
model |
str | None
|
The name of the model to use for answering the query. |
num_answers |
int
|
The number of answers to generate. |
iterative_mode |
bool
|
Whether to answer the query in iterative mode
(see |
budget |
dict[str, float] | None
|
Budget limit (infinite for unspecified metrics). |
cache_dir |
str | None
|
Subdirectory of the global cache directory to use for
caching, or |
cache_mode |
CacheMode
|
Cache mode to use. |
cache_format |
CacheFormat
|
Cache format to use. |
Source code in src/delphyne/stdlib/commands/answer_query.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|