API reference¶
The public API is exported from the top-level remake package. Most pipelines
only need Remake and rule.
Core¶
Source code in src/remake/core/remake.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 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 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 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 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 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
explain_task(task)
¶
(will_run, reasons) for one task — remake why.
Source code in src/remake/core/remake.py
explain_tasks(tasks=None)
¶
Yield (task, will_run, reasons) for each task — batch remake why.
Plans once and reuses the runnable set, so cost is one plan() plus
per-task record/stat checks, not one plan() per task. tasks=None
explains the runnable set itself (bare remake why).
Source code in src/remake/core/remake.py
iter_tasks(query=None)
¶
Lazily yield tasks of all currently-expandable rules, one at a time — constant memory regardless of matrix size.
Rules whose @deferrable matrix raises Defer (an upstream output they need does not exist yet) are skipped with a warning rather than crashing — their task set is unknowable until their upstreams run. This keeps introspection commands (why, task-info, set-state) usable while a dynamic matrix is deferred.
Source code in src/remake/core/remake.py
lint()
¶
Wiring check — the data behind remake lint: every input of a
dependent rule should be produced by one of its depends_on rules.
Returns findings rows sorted near-miss-first, each
{'kind', 'rule', 'other_rule', 'count', 'example'} where kind is
'near_miss' (input matches a near-identical produced path — a likely
typo/off-by-one), 'missing_dependency' (input is produced by a rule
not in depends_on) or 'external' (input produced by no rule).
Materialises all tasks; rules with an unresolved (deferred) matrix are
skipped with a warning.
Source code in src/remake/core/remake.py
rule_dag(*, with_matrix=False)
¶
The rule dependency DAG as data — behind remake rule-dag. Returns
{'order': [rule names, topological], 'edges': {rule: [dependent rule
names]}}. With with_matrix, also 'matrix_info': {rule: (n_tasks,
keys)}, each (None, None) when a dynamic matrix can't be resolved yet
(e.g. a continuation rule awaiting upstream outputs). Builds a fresh DAG
and does not finalize — no metadata backend needed.
Source code in src/remake/core/remake.py
rule_info(rule)
¶
Detail view of one rule as a dict — the data behind remake
rule-info: docstring, dependencies (both directions), matrix
(keys/values/task count, or deferred), input/output path templates
(derived for callables by passing '{kwarg}' placeholders), uses
entries (name/kind/rendering, see scope.raw_uses_parts) and config.
Static introspection only: builds a fresh DAG, touches no metadata.
Source code in src/remake/core/remake.py
run(executor=None, query=None, force=False, ignore_code_changes=False)
¶
Run all tasks that need running, replanning after each wave so dynamic (deferred) matrices resolve as their upstreams complete. Returns the number of failed tasks (0 for asynchronous executors, which don't know at submission time).
Source code in src/remake/core/remake.py
run_task(task)
¶
Execute one task and record the result. The single execution
entry point — used by all executors and remake run-task. Timing and
completion are logged here so every executor gets them uniformly
(per-element detail at TRACE, per-task duration at DEBUG — the
summarise-loops convention, per_task_logging.md).
Source code in src/remake/core/remake.py
select_task(key=None, query=None)
¶
Resolve the single task a command addresses: a key (or unambiguous prefix), or a query matching exactly one task. Raises if both/neither are given, or a query is not uniquely satisfied.
Source code in src/remake/core/remake.py
set_state(query, *, success=False, pending=False, check_outputs=False, cascade=True, dry_run=False)
¶
Set tasks' recorded state by query, without running them.
Exactly one of success/pending. check_outputs (success only)
restricts to tasks whose outputs are complete on disk. cascade
(success only, default on) also re-stamps downstream settled tasks so
they are not left looking stale. dry_run computes the same selection
but writes nothing.
Returns {'state', 'tasks', 'cascaded', 'skipped'}: the selected tasks, the extra tasks restamped by cascade, and the count dropped by check_outputs.
Source code in src/remake/core/remake.py
status_summary(query=None, *, reasons=False, list_tasks=False, list_failures=False)
¶
Per-rule task-status summary — the data behind remake info.
Returns {'rules': [...], 'totals': {...}} plus 'tasks' (when list_tasks) and 'failures' (when list_failures). Rendering, failure grouping and JSON serialisation are the caller's job; this method only gathers. Rules are in dependency (topological) order; deferred rules appear as {'rule', 'deferred': True} with no counts.
Counts are a four-state partition of each rule's tasks — up_to_date + stale + failed + pending == tasks — where a stale task succeeded last run but plan() would rerun it (code/uses/io changed or an upstream reruns). to_run is the plan's view of the same tasks, so up_to_date + to_run == tasks (a success the plan skips is up to date, everything else is to run; an adopted-outputs task under check_outputs='fallback'/'always' counts as up to date).
Source code in src/remake/core/remake.py
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 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
task_from_key(key)
¶
Find a task by key or unambiguous key prefix.
Streams lazily; a full-length key returns on first match. A prefix must scan all tasks to detect ambiguity (hashes are not invertible), but never materialises more than the matches.
Source code in src/remake/core/remake.py
task_from_spec(rule_name, kwargs)
¶
Construct a task directly from (rule name, kwargs) — no search. This is the executor-facing lookup (e.g. SLURM job specs carry rule + kwargs).
Source code in src/remake/core/remake.py
task_info(task)
¶
Detail view of one task as a dict — the data behind remake
task-info: status/timestamp/exception, kwargs, key, input and output
paths (with exists/complete flags), the per-task log path, and the last
SLURM submission's job ids + array index.
Source code in src/remake/core/remake.py
tasks(query=None)
¶
All tasks of all currently-expandable rules. This materialises every task — intended for info/reporting, not planning.
why(key=None, query=None)
¶
Explain why task(s) would (or would not) rerun — the data behind
remake why, with CLI-style selection: one task by key, all matches
for a query, or the runnable set when neither is given. Yields
(task, will_run, reasons) via explain_tasks (one plan() shared).
Source code in src/remake/core/remake.py
The module-level @rule decorator and the Rule descriptor it produces.
Decoration does exactly two things: validate the signature contract and run scope analysis. Registration with a Remake instance happens separately (rules are free-standing, importable objects).
Rule
dataclass
¶
Source code in src/remake/core/rule.py
source
property
¶
Source representation of each part, for metadata storage and change detection. Callables by source, dicts by repr.
check_io_spec(rule_name, part_name, spec, matrix_keys)
¶
Validate an inputs/outputs spec against the matrix keys.
A mismatch here is rule plumbing, not a task problem: resolution is per-task and lazy, so without this check an inputs function whose signature doesn't match the matrix (or a template naming a non-existent kwarg) fails identically for every task, N times, at run time. Raise once, early, naming the rule instead. Called at decoration for static matrices and at first expansion for callable ones (the same split as the run-function signature check).
Source code in src/remake/core/rule.py
deferrable(matrix_fn)
¶
Mark a matrix callable as deferrable: it derives its task list from
upstream outputs and may raise Defer.
Only @deferrable matrices may defer — raising Defer from an unmarked
matrix is an error (it makes the dynamic contract explicit at the call
site). The planner also defers a @deferrable rule when an upstream is
rerunning this wave, so its matrix never expands from a stale output.
Source code in src/remake/core/rule.py
is_deferrable(matrix)
¶
rule(*, inputs=None, outputs=None, matrix=None, depends_on=None, uses=None, strict_scope=None, config=None, name=None)
¶
Define a rule. Returns a free-standing Rule object (not the function).
See remake3_design.md for the full parameter semantics.
Source code in src/remake/core/rule.py
Source code in src/remake/core/rule.py
source
property
¶
Source representation of each part, for metadata storage and change detection. Callables by source, dicts by repr.
Source code in src/remake/core/task.py
Mark a matrix callable as deferrable: it derives its task list from
upstream outputs and may raise Defer.
Only @deferrable matrices may defer — raising Defer from an unmarked
matrix is an error (it makes the dynamic contract explicit at the call
site). The planner also defers a @deferrable rule when an upstream is
rerunning this wave, so its matrix never expands from a stale output.
Source code in src/remake/core/rule.py
Bases: Exception
Raised by a @deferrable matrix callable to signal that the rule
cannot be expanded this wave — its task list derives from an upstream
output that does not yet exist. A control-flow signal, not an error
(hence not a RemakeError): the planner defers the rule and the replan
loop / SLURM continuation job retries it once the upstream completes.
The planner additionally defers a @deferrable rule when an upstream is
rerunning this wave (its on-disk output is stale), so the matrix never
expands from an about-to-be-overwritten output.
Accepts path strings as context, surfaced to the user to show what is blocking resolution.
Source code in src/remake/core/exceptions.py
Errors¶
Bases: RemakeError
Rule function uses undeclared names from outer scope (strict mode).
Bases: RemakeError
Rule function signature does not match its declarations.
Executors¶
Bases: ABC
Source code in src/remake/executors/executor.py
run_tasks(tasks)
abstractmethod
¶
Run tasks; return the number that failed (None counts as 0 — asynchronous executors don't know yet at submission time).
Bases: Executor
Source code in src/remake/executors/singleproc_executor.py
Bases: Executor
Source code in src/remake/executors/multiproc_executor.py
Bases: Executor
Source code in src/remake/executors/slurm_executor.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
Bases: Executor
Source code in src/remake/executors/dask_executor.py
Output tokens¶
Bases: ABC
Source code in src/remake/core/tokens.py
Bases: OutputToken
Source code in src/remake/core/tokens.py
Loading & metadata¶
Load a pipeline file and return its Remake instance.
Source code in src/remake/loader/__init__.py
Bases: ABC
Source code in src/remake/metadata/metadata_manager.py
begin_invocation()
¶
Start a new logical invocation: allocate a fresh run_seq so tasks committed from here share one stamp, distinct from earlier invocations. A no-op for backends without a persistent counter.
current_run_seq()
¶
This invocation's run_seq (a monotonic stamp shared by every task it commits). Backends without a persistent counter return None — no durable propagation, only in-pass.
delete_tasks(tasks)
¶
ensure_rules(rules, remakefile=None)
abstractmethod
¶
Create/update stored rule metadata (source code) for these rules.
remakefile records which file defined them (provenance + the
duplicate-rule-name guard).
get_codes(code_ids)
¶
{code_id: text} for the given ids (a TaskRecord's run_code_id/uses_code_id/io_code_id). Backends without a code store have nothing to resolve; None ids are ignored.
get_tasks_status(tasks)
abstractmethod
¶
get_uses_manifest(uses_code_id)
¶
{name: (raw-rendering, kind)} for the helpers behind a stored uses version (a TaskRecord's uses_code_id) — see scope.raw_uses_parts for the kinds. Display only; empty when unknown (backends without a store, or records predating the manifest table).
Source code in src/remake/metadata/metadata_manager.py
ingest_sidecars(rules)
¶
Absorb pending sidecar result files (written by per-task array processes) for these rules. Backends without a persistent store have nothing to ingest into; default is a no-op.
update_task(task, status, exception='')
abstractmethod
¶
update_tasks(tasks, status, exception='')
¶
Record the same state for many tasks (backends may batch).
Bases: MetadataManager
Source code in src/remake/metadata/sqlite3_backend.py
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 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 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 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 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | |
begin_invocation()
¶
Allocate a fresh run_seq for a new logical invocation (a run() or
a set-state), so repeated invocations on one backend instance still
advance — the CLI starts a fresh process each time, but programmatic
callers reuse the object.
Source code in src/remake/metadata/sqlite3_backend.py
current_run_seq()
¶
This invocation's run_seq, allocating it on first use. Every task committed in the invocation shares the value, so a single run/set-state stamps one logical 'wave' (cross-node-safe: assigned here, not read from a compute node's clock).
Source code in src/remake/metadata/sqlite3_backend.py
ingest_sidecars(rules)
¶
Absorb pending sidecar results (written by run-array-task) into the DB — one batched transaction for the lot, sidecars deleted after commit. Cheap when there is nothing to ingest.
Source code in src/remake/metadata/sqlite3_backend.py
A task's stored execution state. The planner consumes these; Task objects themselves stay pure value objects.
Code/uses/io are carried as integer ids into the content-addressed code
table, not as text — fetching the text per task is what made status
queries scale with task count (design_docs/logs_analysis/README.md §1.2).
Consumers resolve ids to text via MetadataManager.get_codes, once per
distinct id rather than once per task.