Pipelines¶
The decorators that build a pipeline, the pipeline object they return, and the errors raised while building or running it. See the Decorators and Snapshots & sweeps guides for usage.
Decorators¶
interactive
¶
interactive(inplace: Union[bool, Callable] = False, **decorator_controls: Any)
Declare controls bound to a filter's keyword arguments.
The decorated function keeps working as a plain function, but when used
inside an @interactive_pipeline the declared controls appear as GUI
widgets. Unlike @interact, no GUI is launched at decoration time,
so the filter can be reused across pipelines.
Controls can also be declared by the filter's own annotations (see
docs/guide/controls.md): Annotated[float, (0.0, 3.0)],
Annotated[bool, "label"], Annotated[T, Control(...)],
Literal["a", "b"] and Enum hints make widgets, the default comes from
the signature. A plain gain: float = 1.0 makes no widget. A decorator
argument wins over an annotation. @interactive also works without
parentheses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inplace
|
Union[bool, Callable]
|
Declare that this filter mutates its input buffers. The
engine then hands it private writable copies instead of
read-only views. Prefer copying explicitly
( |
False
|
**decorator_controls
|
Any
|
Mapping of keyword-argument name to a control
declaration — a |
{}
|
Example
@interactive(gain=(1.0, [0.0, 3.0]))
def amplify(img, gain=1.0):
return gain * img
@interactive()
def amplify_typed(img, gain: Annotated[float, (0.0, 3.0)] = 1.0):
return gain * img
Source code in src/interactive_pipe/helper/filter_decorator.py
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 | |
interactive_pipeline
¶
interactive_pipeline(gui: Union[str, Backend, None] = 'auto', safe_input_buffer_deepcopy: Optional[bool] = None, cache: Union[bool, str] = False, readonly_inputs: bool = True, context: Optional[dict] = None, markdown_description: Optional[str] = None, name: Optional[str] = None, **kwargs_gui: Any) -> Callable[[Callable[..., Any]], Union[HeadlessPipeline, Callable[..., Any]]]
Decorator turning a pipeline function into an interactive GUI application.
The decorated function chains filters (typically declared with
@interactive) and is analyzed statically to build the execution
graph. Its body must therefore contain only filter-function calls
(possibly nested, with literal keyword arguments such as
amplify(img, gain=2.0)), assignments and one final return — no
control flow (if/for/while) or arithmetic; put such logic inside the
filters themselves. Anything else raises PipelineSyntaxError at
decoration time, naming the line and the fix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gui
|
Union[str, Backend, None]
|
Backend used to display the pipeline. One of |
'auto'
|
safe_input_buffer_deepcopy
|
Optional[bool]
|
Deep-copy the input buffers before each
run. None (default) copies only inputs that the read-only
machinery cannot protect (anything but numpy arrays / torch
tensors when |
None
|
readonly_inputs
|
bool
|
Hand filters their numpy inputs as read-only views
(default True), so in-place mutation ( |
True
|
cache
|
Union[bool, str]
|
Cache intermediate filter outputs between runs.
- False (default): recompute every filter on every interaction.
- True: sequential prefix cache - a change recomputes every
filter after it in source order.
- "graph": dependency-aware cache - only filters actually
affected by a change are recomputed, following the data-flow
graph and runtime-tracked |
False
|
context
|
Optional[dict]
|
Initial content of the shared context dictionary, readable
and writable from filters through the |
None
|
markdown_description
|
Optional[str]
|
Description displayed by backends that support it (e.g. Gradio). |
None
|
name
|
Optional[str]
|
Window/application title. Defaults to the function name. |
None
|
**kwargs_gui
|
Any
|
Extra options forwarded to the GUI backend,
e.g. |
{}
|
Environment overrides (read when the decorator is applied):
INTERACTIVE_PIPE_GUI (auto/qt/dpg/mpl/nb/gradio/headless/none)
replaces gui when it is "auto" (the default), and
INTERACTIVE_PIPE_SIZE ("fullscreen", "maximized" or "WxH")
provides size when none is given. Explicit arguments win over
the environment; interactive_pipe.cli.parse_gui_args values are
explicit arguments, so the command line wins over both.
``INTERACTIVE_PIPE_SNAPSHOT`` (a PNG path or folder, ``{name}`` is
replaced by the function name): when set, any GUI ``gui`` value
returns a launcher that renders a snapshot there and returns the
results instead of opening a window (``gui=None`` is unaffected).
Returns:
| Type | Description |
|---|---|
Callable[[Callable[..., Any]], Union[HeadlessPipeline, Callable[..., Any]]]
|
A decorator. Applied to a pipeline function it returns either a |
Callable[[Callable[..., Any]], Union[HeadlessPipeline, Callable[..., Any]]]
|
|
Callable[[Callable[..., Any]], Union[HeadlessPipeline, Callable[..., Any]]]
|
callable that launches the GUI when invoked with the pipeline inputs. |
Callable[[Callable[..., Any]], Union[HeadlessPipeline, Callable[..., Any]]]
|
Both have |
Callable[[Callable[..., Any]], Union[HeadlessPipeline, Callable[..., Any]]]
|
|
Callable[[Callable[..., Any]], Union[HeadlessPipeline, Callable[..., Any]]]
|
opening a window (whatever |
Callable[[Callable[..., Any]], Union[HeadlessPipeline, Callable[..., Any]]]
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a removed pre-0.9.0 context alias ( |
PipelineSyntaxError
|
If the pipeline body contains a statement the static analysis cannot express (see the guide). |
Example
@interactive_pipeline(gui="qt", cache=True)
def my_pipeline(img):
flipped = flip(img)
amplified = amplify(flipped)
return flipped, amplified
my_pipeline(input_image) # opens the interactive window
Source code in src/interactive_pipe/helper/pipeline_decorator.py
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 | |
interact
¶
interact(*decorator_args: Any, gui: str = 'auto', disable: bool = False, output_routing: Optional[List[str]] = None, size: Union[str, Tuple[int, int], None] = None, inplace: bool = False, **decorator_controls: Any)
Launch a GUI from a single decorated function (one-shot decorator).
Unlike @interactive, decorating a function with @interact
immediately runs it inside a GUI: widgets are created for the declared
controls and the window opens right away. Inspired by the ipywidgets
interact function, except that returning numpy arrays or Curve
instances handles the display automatically — no matplotlib boilerplate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*decorator_args
|
Any
|
Positional inputs passed to the function (e.g. the input image). |
()
|
gui
|
str
|
Backend, same values as |
'auto'
|
disable
|
bool
|
When True, return the function untouched (no GUI). |
False
|
output_routing
|
Optional[List[str]]
|
Names of the outputs, when they cannot be deduced from a dry run. |
None
|
size
|
Union[str, Tuple[int, int], None]
|
Window/figure size hint forwarded to the backend. |
None
|
**decorator_controls
|
Any
|
Controls bound to keyword arguments by name
( |
{}
|
Example
@interact(image, gain=(1.0, [0.0, 3.0]))
def show(img, gain=1.0):
return img * gain
Source code in src/interactive_pipe/helper/filter_decorator.py
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 | |
Pipeline object¶
@interactive_pipeline(gui=None) returns a HeadlessPipeline;
HeadlessPipeline.from_function(fn) builds one without the decorator. GUI
pipelines expose snapshot, sweep, describe and summary too, and every
@interactive filter has .snapshot(), .sweep(), .describe(),
.summary() and .interact(img) running it alone.
HeadlessPipeline
¶
Bases: PipelineCore
PipelineCore extensions - saving/loading to disk - graphs - init from interpreted functions
Adds some powerful features to the pipeline core such as: - creating a pipeline from a function as a sequential filter - importing/exporting parameters ("tuning") as json or yaml - saving output images - printing current parameters in the terminal - graph representation
Source code in src/interactive_pipe/headless/pipeline.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 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 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 | |
from_function
classmethod
¶
from_function(pipe: Callable[..., Any], inputs=None, *, _routing_by_indexes=False, **kwargs)
Source code in src/interactive_pipe/headless/pipeline.py
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 | |
__call__
¶
__call__(*inputs_tuple, inputs=None, parameters=None, context=None, **kwargs) -> Any
Run the pipeline once and return its outputs.
Example
blurred, edges = pipe(img, sigma=2.0)
(single,) = pipe1(img) # always a tuple, even for one output
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*inputs_tuple
|
Pipeline inputs, in the order of the pipeline function's arguments. |
()
|
|
inputs
|
Inputs as a |
None
|
|
parameters
|
|
None
|
|
context
|
Values merged into the shared |
None
|
|
**kwargs
|
Parameter values: a parameter name (every filter having it), a
control name or |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
A tuple of the outputs in |
Any
|
function returns a 2D list), or None when the pipeline returns |
Any
|
nothing. A |
Raises:
| Type | Description |
|---|---|
TypeError
|
unknown keyword / wrong number of inputs. |
FilterError
|
a filter raised (the message names the filter and the line). |
Source code in src/interactive_pipe/headless/pipeline.py
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 | |
run
¶
run()
Run once; the outputs in the display layout (self.outputs, which
layout.grid and the GUIs change), as the windows and snapshots show them.
Source code in src/interactive_pipe/headless/pipeline.py
551 552 553 554 555 556 557 558 | |
snapshot
¶
snapshot(pipeline: HeadlessPipeline, path: PathLike, *input_values: Any, inputs: Optional[dict] = None, output: OutputSelector = None, params: Optional[Dict[str, Any]] = None, figsize: Optional[Tuple[float, float]] = None, dpi: Optional[float] = None, title: Optional[str] = None, caption: Union[bool, str, None] = True, runs: int = 1, **overrides: Any) -> Union[Path, np.ndarray]
Run the pipeline once and render what the GUI would show to a PNG.
Each call starts like a first run: the context holds only what was given
from outside (context= at construction or in a call), not what filters
wrote in earlier runs; key-bound events are off and nothing is served from
the cache. The pipeline's own context, events and cache are put back
afterwards. A pipeline that needs warm-up runs (an accumulator, a
simulation) takes runs=N: N runs from that fresh start, the last one shown.
Example
pipe.snapshot("out.png", img, gain=2.0)
rgb = pipe.snapshot(None, img) # (H, W, 3) uint8 array, no file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
PNG file to write (parent folders are created); None returns
the rendered image as an |
required |
*input_values
|
Any
|
Pipeline inputs. May be omitted when the pipeline takes none, or to reuse the inputs of the previous call / run. |
()
|
inputs
|
Optional[dict]
|
Inputs as a |
None
|
output
|
OutputSelector
|
Render only some outputs: a name, an index (reading order) or a list of them. Default: the whole layout. |
None
|
params
|
Optional[Dict[str, Any]]
|
Parameter overrides as a dict - use it for names that clash
with the options of this method ( |
None
|
figsize
|
Optional[Tuple[float, float]]
|
Figure size in inches. Default: derived from the layout and the image aspect ratios. |
None
|
dpi
|
Optional[float]
|
Resolution. Default: showing the largest image near its native size (80 to 150 dpi). |
None
|
title
|
Optional[str]
|
Figure title. |
None
|
caption
|
Union[bool, str, None]
|
True (default) prints the parameter values used under the grid, False hides them, a string replaces them. |
True
|
runs
|
int
|
Number of runs from the fresh start (default 1); the last one is shown. |
1
|
**overrides
|
Any
|
Parameter values for this call only: a keyword-argument
name ( |
{}
|
Returns:
| Type | Description |
|---|---|
Union[Path, ndarray]
|
The written path, or the image when |
Raises:
| Type | Description |
|---|---|
TypeError
|
unknown parameter name (the message lists the available ones), or missing inputs. |
FilterError
|
a filter raised during the run (state is restored). |
Source code in src/interactive_pipe/headless/explore.py
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 | |
sweep
¶
sweep(pipeline: HeadlessPipeline, path: PathLike, *input_values: Any, inputs: Optional[dict] = None, output: Any = None, steps: Optional[Dict[str, int]] = None, params: Optional[Dict[str, Any]] = None, figsize: Optional[Tuple[float, float]] = None, dpi: Optional[float] = None, title: Optional[str] = None, caption: Union[bool, str, None] = True, runs: int = 1, **overrides: Any) -> Union[Path, np.ndarray]
Run the pipeline for several parameter values and render a contact sheet.
Every cell starts like a first run (see snapshot): cells are
independent of each other and of the runs before the call.
Example
pipe.sweep("sweep.png", img, gain=[0.5, 1, 2]) # one row
pipe.sweep("grid.png", img, gain=[0.5, 2], blur=[1, 3, 5]) # 2 x 3 grid
pipe.sweep("steps.png", img, steps={"gain": 5}) # 5 values over the slider range
pipe.sweep("all.png", img, gain=[0.5, 2], output="all") # every output per cell
A list, tuple or numpy array is a swept axis; a scalar is a fixed override
applied to every cell. For a range parameter (RangeControl) a tuple is
one (lo, hi) value: sweep it with a list of pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
PNG to write, or None to get the image as an (H, W, 3) uint8 array. |
required |
*input_values
|
Any
|
Pipeline inputs (optional when reusing the previous ones). |
()
|
inputs
|
Optional[dict]
|
Inputs as a dict instead. |
None
|
output
|
Any
|
Output shown in each cell: a name or an index. Default: the
only output, else the first image output that the swept
parameters change (downstream of their filters), else the last
image output. |
None
|
steps
|
Optional[Dict[str, int]]
|
|
None
|
params
|
Optional[Dict[str, Any]]
|
Overrides / axes as a dict (for names clashing with options). |
None
|
figsize
|
Optional[Tuple[float, float]]
|
As for |
None
|
dpi
|
Optional[float]
|
As for |
None
|
title
|
Optional[str]
|
As for |
None
|
caption
|
Union[bool, str, None]
|
True prints the fixed parameter values under the sheet. |
True
|
runs
|
int
|
Runs per cell from the fresh start (default 1); the last one is shown. |
1
|
**overrides
|
Any
|
Swept axes (lists) and fixed overrides (scalars). |
{}
|
Returns:
| Type | Description |
|---|---|
Union[Path, ndarray]
|
The written path, or the image when |
Raises:
| Type | Description |
|---|---|
ValueError
|
nothing to sweep, or more than two swept parameters. |
TypeError
|
unknown parameter name, or missing inputs. |
FilterError
|
a filter raised (state is restored). |
Source code in src/interactive_pipe/headless/explore.py
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 | |
describe
¶
describe(pipeline: HeadlessPipeline) -> Dict[str, Any]
Describe the pipeline as a JSON-serialisable dict.
Keys
name: pipeline name.
inputs: input names, in call order.
outputs: output layout (flat list = one row, list of lists = grid,
None = empty cell).
filters: in execution order, each with its input / output variable
names, current parameter values, control names and docstring line.
controls: name, owning filter, parameter, targets (every
"filter.parameter" it drives: several for a control shared by
several filters), kind (slider / number /
checkbox / dropdown / range / text / time / keyboard / point /
region, with on: the target output, None for the first
image), type,
default, current value, range or choices, step, scale: "log" for a
log slider, group, key
bindings and tooltip when present.
Example
import json
print(json.dumps(pipe.describe(), indent=2))
print(pipe.summary()) # the same, as text
Source code in src/interactive_pipe/headless/describe.py
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 | |
summary
¶
summary(pipeline: HeadlessPipeline) -> str
Readable text version of describe() (print(pipe.summary())).
Source code in src/interactive_pipe/headless/describe.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
save
¶
save(path: Optional[Path] = None, data_wrapper_fn: Optional[Callable[..., Any]] = None, output_indexes: Optional[list] = None, save_entire_buffer: bool = False) -> List[Path]
Run the pipeline and write its outputs (and the tuning) next to path.
Output name is written to <stem>_<name><suffix>, the current
parameters to <stem>.yaml. The format follows the output type:
- numpy image (
(H, W),(H, W, 1|3|4); float in[0, 1], uint8, uint16 or bool) -> image file throughImage(path's suffix if it is.png/.jpg/.tif, else.png) - 1D numpy array ->
.csv; any other numpy array ->.npy Image,Curve,SingleCurve,Table-> their ownsave(path's suffix when they support it, else their default one)str->.txt
Other output types are skipped with a single warning. Pass
data_wrapper_fn to wrap every output yourself (it must return an
object with a save(path) method).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
Base file path, e.g. |
None
|
data_wrapper_fn
|
Optional[Callable[..., Any]]
|
Optional wrapper applied to each output. |
None
|
output_indexes
|
Optional[list]
|
Names (or indexes) of the buffers to save; defaults to the pipeline outputs. |
None
|
save_entire_buffer
|
bool
|
Save every intermediate buffer. |
False
|
Returns:
| Type | Description |
|---|---|
List[Path]
|
The list of written output files (the tuning file excluded). |
Source code in src/interactive_pipe/headless/pipeline.py
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 | |
export_tuning
¶
export_tuning(path: Optional[Path] = None, override=False) -> None
Export the current parameters of every filter to a json/yaml file
Source code in src/interactive_pipe/headless/pipeline.py
479 480 481 482 | |
load_tuning
¶
load_tuning(path: Path) -> None
Load a json/yaml tuning file written by export_tuning (alias of import_tuning).
Example
pipe.export_tuning("my_tuning.yaml")
pipe.load_tuning("my_tuning.yaml")
Source code in src/interactive_pipe/headless/pipeline.py
493 494 495 496 497 498 499 500 501 502 | |
graph_representation
¶
graph_representation(path=None, ortho=True, view=False, format=None)
Draw the pipeline graph: inputs, filters (with their parameters), outputs.
By default writes one standalone HTML page (inline SVG, no dependency,
opens in any browser) and returns its Path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
file to write. Default: |
None
|
|
ortho
|
graphviz only: orthogonal edges. |
True
|
|
view
|
open the result (the HTML page in the web browser; never
under |
False
|
|
format
|
|
None
|
Example
path = pipe.graph_representation("my_pipeline.html")
dot = pipe.graph_representation("my_pipeline", format="pdf") # graphviz
Source code in src/interactive_pipe/headless/pipeline.py
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 767 768 769 770 771 772 773 774 775 776 777 | |
export_animation
¶
export_animation(pipeline: HeadlessPipeline, path: Union[str, Path], *, duration: Optional[float] = None, fps: Optional[float] = None, time_control: Optional[Union[str, TimeControl, TimelineControl]] = None, output: Union[int, Tuple[int, int], None] = None, loop: int = 0) -> Path
Render duration seconds of a TimeControl-driven pipeline to disk.
Frame k is rendered with the time control set to k / fps seconds.
A pipeline whose input is a Video (and without TimeControl) renders its
timeline instead: every frame by default, at the video frame rate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline
|
HeadlessPipeline
|
pipeline holding a |
required |
path
|
Union[str, Path]
|
|
required |
duration
|
Optional[float]
|
animation length in seconds (default 5 s; a video: all of it). |
None
|
fps
|
Optional[float]
|
frames per second (default 10; a video: its frame rate). |
None
|
time_control
|
Optional[Union[str, TimeControl, TimelineControl]]
|
name (or instance) of the TimeControl to drive; required
only when the pipeline has several. The timeline of a |
None
|
output
|
Union[int, Tuple[int, int], None]
|
which output to record: an index into the output tuple, a
|
None
|
loop
|
int
|
GIF loop count (0 = forever). |
0
|
Returns:
| Type | Description |
|---|---|
Path
|
The written GIF path, or the directory holding the PNG frames. |
The control's previous value is restored (and the pipeline re-run) afterwards.
Source code in src/interactive_pipe/headless/animation.py
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 | |
Errors¶
PipelineSyntaxError
¶
Bases: ValueError
A pipeline function contains a statement the static graph analysis cannot express.
Raised when the pipeline is built (decoration time). The message names the
pipeline, the file and line, the offending source line and a hint on how to
rewrite it. Subclass of ValueError so existing except ValueError
code keeps working.
Attributes:
| Name | Type | Description |
|---|---|---|
pipeline_name |
Name of the pipeline function. |
|
filename |
Source file of the pipeline function. |
|
lineno |
Absolute line number of the offending statement in |
|
source_line |
The offending source line. |
|
hint |
Suggested fix. |
Source code in src/interactive_pipe/core/graph.py
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
FilterError
¶
Bases: Exception
Clean, user-friendly exception for filter errors.
Displays only the relevant error information without the full framework traceback, making it easier to identify issues in user code.
Source code in src/interactive_pipe/core/engine.py
18 19 20 21 22 23 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 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 | |
DisplayError
¶
Bases: ValueError
An output array that cannot be displayed without guessing its layout
(channel-first, batch, empty, object / complex dtype...). The message names
the output (and the filter returning it) and the fix. Raised by
prepare_display: by snapshot / sweep; a GUI window shows the
message in the cell instead and keeps running.
Source code in src/interactive_pipe/graphical/display.py
789 790 791 792 793 794 | |