Skip to content

Commit 2574a33

Browse files
committed
Add dbos plugin
1 parent aaa2e19 commit 2574a33

44 files changed

Lines changed: 5064 additions & 1144 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,13 @@ Linting, typechecking, and formatting:
7474
```bash
7575
uv run --directory packages/llama-index-workflows pre-commit run -a
7676
```
77+
78+
## Testing Patterns
79+
80+
We use **pytest** with idiomatic pytest patterns. Follow these guidelines:
81+
82+
- **No Test Classes**: Do not use test classes to organize tests. Write tests as standalone functions. Achieve organization through descriptive function names (e.g., `test_create_job_with_invalid_input_raises_error`) or by splitting into separate test files.
83+
- **Pytest Fixtures**: Use fixtures for setup/teardown and shared test dependencies. Prefer fixtures over manual setup code repeated across tests.
84+
- **Prefer Real Objects Over Mocks**: Use simple dataclasses and real objects directly when available rather than mocking them. Only mock external dependencies or things that are truly difficult to instantiate.
85+
- **DRY Test Setup**: Do not repeat patches or setup code. Create reusable abstractions—fixtures, helper functions, or module-level constants—that can be shared across tests. Tests can easily be overwhelmed with setup; start from a rich suite of testing utilities to enable many small, expressive tests.
86+
- **Simple Testing Utilities**: Testing utilities should be basic—just functions, fixtures, and global variables. Avoid over-engineering test infrastructure.

packages/llama-index-utils-workflow/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ authors = [{name = "Adrian Lyjak", email = "adrianlyjak@gmail.com"}]
1919
requires-python = ">=3.9"
2020
dependencies = [
2121
"llama-index-core>=0.14,<0.15.0",
22-
"llama-index-workflows>=2.12.0,<3.0.0",
22+
"llama-index-workflows>=2.13.0,<3.0.0",
2323
"pyvis>=0.3.2"
2424
]
2525

packages/llama-index-utils-workflow/src/llama_index/utils/workflow/__init__.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from llama_index.core.tools import AsyncBaseTool, BaseTool
1313
from pyvis.network import Network
1414
from workflows import Workflow
15+
from workflows.context.external_context import ExternalContext
1516
from workflows.events import (
1617
Event,
1718
StartEvent,
@@ -46,15 +47,15 @@ def _get_node_color(node: WorkflowGraphNode) -> str:
4647
elif node.node_type == "resource":
4748
return "#DDA0DD" # Plum/light purple for resources
4849
elif node.node_type == "event":
49-
if node.is_subclass_of("StartEvent"):
50+
if node.is_subclass_of("StartEvent"): # type: ignore[possibly-missing-attribute]
5051
return "#E27AFF" # Pink for start events
51-
elif node.is_subclass_of("StopEvent"):
52+
elif node.is_subclass_of("StopEvent"): # type: ignore[possibly-missing-attribute]
5253
return "#FFA07A" # Orange for stop events
5354
return "#90EE90" # Light green for other events
5455
elif node.node_type == "agent":
55-
if node.is_subclass_of("ReActAgent"):
56+
if node.is_subclass_of("ReActAgent"): # type: ignore[possibly-missing-attribute]
5657
return "#E27AFF"
57-
elif node.is_subclass_of("CodeActAgent"):
58+
elif node.is_subclass_of("CodeActAgent"): # type: ignore[possibly-missing-attribute]
5859
return "#66ccff"
5960
return "#90EE90"
6061
elif node.node_type == "tool":
@@ -172,15 +173,15 @@ def _get_mermaid_css_class(node: WorkflowGraphNode) -> str:
172173
elif node.node_type == "resource":
173174
return "resourceStyle"
174175
elif node.node_type == "event":
175-
if node.is_subclass_of("StartEvent"):
176+
if node.is_subclass_of("StartEvent"): # type: ignore[possibly-missing-attribute]
176177
return "startEventStyle"
177-
elif node.is_subclass_of("StopEvent"):
178+
elif node.is_subclass_of("StopEvent"): # type: ignore[possibly-missing-attribute]
178179
return "stopEventStyle"
179180
return "defaultEventStyle"
180181
elif node.node_type == "agent":
181-
if node.is_subclass_of("ReActAgent"):
182+
if node.is_subclass_of("ReActAgent"): # type: ignore[possibly-missing-attribute]
182183
return "reactAgentStyle"
183-
elif node.is_subclass_of("CodeActAgent"):
184+
elif node.is_subclass_of("CodeActAgent"): # type: ignore[possibly-missing-attribute]
184185
return "codeActAgentStyle"
185186
return "defaultAgentStyle"
186187
elif node.node_type == "tool":
@@ -435,10 +436,12 @@ def _extract_execution_graph(
435436
handler: WorkflowHandler, max_label_length: int | None = None
436437
) -> Tuple[Dict[str, Tuple[str, str, type | None]], List[Tuple[str, str]]]:
437438
"""Helper to extract nodes and edges from the workflow handler's tick log."""
438-
if handler.ctx is None or handler.ctx._broker_run is None:
439-
raise ValueError("No context/run info in this handler. Has it been run yet?")
440439

441-
ticks: List[WorkflowTick] = handler.ctx._broker_run._tick_log
440+
ticks: List[WorkflowTick] = []
441+
if handler.ctx is not None:
442+
face = handler.ctx._face
443+
if isinstance(face, ExternalContext):
444+
ticks = face._tick_log
442445
nodes: Dict[str, Tuple[str, str, type | None]] = {}
443446
edges: List[Tuple[str, str]] = []
444447
event_node_by_identity: Dict[int, str] = {}

packages/llama-index-workflows/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies = [
3737
[project.optional-dependencies]
3838
server = ["starlette>=0.39.0", "uvicorn>=0.32.0"]
3939
client = ["httpx>=0.28.1,<1"]
40+
dbos = ["dbos>=1.14.0"]
4041

4142
[tool.hatch.envs.server]
4243
features = ["server"]

0 commit comments

Comments
 (0)