teff.yaml¶
teff.yaml
¶
YAML serialisation and deserialisation for graphs.
Functions:
| Name | Description |
|---|---|
checkpointer_from_workflow |
Build the checkpointer declared by a workflow's |
from_yaml |
Parse a YAML string or file path into a |
graph_to_yaml |
Serialize a |
load_workflow |
Load a complete workflow from a YAML file (graph + tools + state). |
load_workflow_document |
Read path and resolve env refs and |
workflow_to_yaml |
Serialize a |
checkpointer_from_workflow
¶
checkpointer_from_workflow(path)
Build the checkpointer declared by a workflow's checkpoint: block.
Returns None when the workflow has no checkpoint: block.
Relative path values are resolved against the workflow file's
directory; dsn values are passed through verbatim.
Source code in teff/yaml.py
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | |
from_yaml
¶
from_yaml(source)
Parse a YAML string or file path into a Graph.
The YAML format::
name: my-graph
steps:
- id: start
type: transform
config: {action: "uppercase"}
edges:
- from: start
to: next
If source is an existing file path it is read from disk; otherwise it is treated as a raw YAML string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
YAML string or path to a |
required |
Returns:
| Type | Description |
|---|---|
Graph
|
A compiled |
Source code in teff/yaml.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 448 449 450 451 452 453 454 455 456 | |
graph_to_yaml
¶
graph_to_yaml(graph)
Serialize a Graph instance to a YAML string.
This is shorthand for :func:workflow_to_yaml without tools or state.
Source code in teff/yaml.py
613 614 615 616 617 618 | |
load_workflow
¶
load_workflow(path)
Load a complete workflow from a YAML file (graph + tools + state).
YAML format::
name: my-workflow
tools:
- type: calculator
- type: shell
config: {root_dir: /tmp}
state:
schema:
messages:
reducer: append
type: list
initial:
status: active
steps:
- id: step1
type: transform
config: {action: uppercase, input_key: text, output_key: out}
edges:
- from: step1
to: step2
Returns:
| Type | Description |
|---|---|
tuple[Graph, list[Tool | McpToolGroup], dict, dict[str, Reducer]]
|
A |
Source code in teff/yaml.py
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 | |
load_workflow_document
¶
load_workflow_document(path)
Read path and resolve env refs and include: blocks.
Returns the fully expanded document (interpolated, includes merged)
— the same surface :func:load_workflow validates — without building
any nodes or tools.
Source code in teff/yaml.py
57 58 59 60 61 62 63 64 65 66 67 68 | |
workflow_to_yaml
¶
workflow_to_yaml(graph, *, tools=None, initial=None, reducers=None, name='graph')
Serialize a Graph (plus optional tools/state) to a workflow YAML.
steps and edges come from the graph; tools are written
from their name and (when present) their config attribute;
reducers become the state.schema block (string reducers only)
and initial becomes state.initial.
The output validates with :func:validate_workflow and round-trips
through :func:load_workflow.
Source code in teff/yaml.py
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 | |