-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_examples_smoke.py
More file actions
56 lines (46 loc) · 1.84 KB
/
Copy pathtest_examples_smoke.py
File metadata and controls
56 lines (46 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
"""Smoke test: load each example's ``main.py`` and invoke its
``build_graph()`` factory.
We don't run the demo end-to-end — that would hit a local OpenAI-
compatible LLM endpoint that isn't available in CI. But loading the
module and compiling its graph catches:
- syntax errors,
- accidental breakage in openarmature's public API that would only
otherwise surface when a user runs the demo,
- missing imports (e.g. a renamed symbol that the demo still
references),
- graph-compile failures in the demo's structure (dangling edges,
unreachable nodes, conflicting reducers, missing entry, etc.).
``runpy.run_path`` with ``run_name`` set to a sentinel skips the
example's ``if __name__ == "__main__":`` block, so we get the
module-level import side-effects without firing any LLM calls.
``build_graph()`` is a convention every demo exposes — invoking it
exercises the same compile path the demo's ``main()`` does.
"""
from __future__ import annotations
import runpy
from pathlib import Path
import pytest
EXAMPLES_DIR = Path(__file__).parent.parent / "examples"
DEMOS = [
"00-hello-world",
"01-routing-and-subgraphs",
"02-explicit-subgraph-mapping",
"03-observer-hooks",
"04-nested-subgraphs",
"05-fan-out-with-retry",
"06-parallel-branches",
"07-multimodal-prompt",
"08-checkpointing-and-migration",
"09-tool-use",
"10-langfuse-observability",
"11-chat-with-multimodal",
"12-production-observability",
]
@pytest.mark.parametrize("demo", DEMOS)
def test_example_loads(demo: str) -> None:
main_py = EXAMPLES_DIR / demo / "main.py"
assert main_py.exists(), f"missing: {main_py}"
module_globals = runpy.run_path(str(main_py), run_name="__not_main__")
build_graph = module_globals.get("build_graph")
assert callable(build_graph), f"{demo}/main.py missing build_graph() factory"
build_graph()