Skip to content

Commit 0ebdf1d

Browse files
authored
Fix dbos local setup (#10)
* Fix DBOS demos: wait for result * formatting
1 parent 2ada4db commit 0ebdf1d

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

durable-exec/deep_research_dbos.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,21 @@ async def deep_research_durable(query: str):
115115
'name': 'deep_research_durable',
116116
'enable_otlp': True,
117117
'conductor_key': os.environ.get('DBOS_CONDUCTOR_KEY', None),
118+
'application_version': '0.1.0',
118119
}
119120
DBOS(config=config)
120121
DBOS.launch()
121122
resume_id = sys.argv[1] if len(sys.argv) > 1 else None
122123
wf_id = f'deep-research-{uuid.uuid4()}'
123124
if resume_id is not None:
124125
print('resuming existing workflow', resume_id)
125-
wf_id = resume_id
126+
# Get the workflow handle and wait for the result
127+
wf_handle: WorkflowHandleAsync[str] = await DBOS.retrieve_workflow_async(resume_id)
128+
summary = await wf_handle.get_result()
126129
else:
127130
print('starting new workflow', wf_id)
128-
129-
with SetWorkflowID(wf_id):
130-
summary = await deep_research(query)
131+
with SetWorkflowID(wf_id):
132+
summary = await deep_research(query)
131133

132134
print(summary)
133135

durable-exec/twenty_questions_dbos.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from enum import StrEnum
66

77
import logfire
8-
from dbos import DBOS, DBOSConfig, SetWorkflowID
8+
from dbos import DBOS, DBOSConfig, SetWorkflowID, WorkflowHandleAsync
99
from pydantic_ai import Agent, AgentRunResult, RunContext, UsageLimits
1010
from pydantic_ai.durable_exec.dbos import DBOSAgent
1111

@@ -80,19 +80,21 @@ async def play(resume_id: str | None, answer: str) -> AgentRunResult[str]:
8080
# run the server with
8181
# docker run -e POSTGRES_HOST_AUTH_METHOD=trust --rm -it --name pg -p 5432:5432 -d postgres
8282
'system_database_url': 'postgresql://postgres@localhost:5432/dbos',
83+
'application_version': '0.1.0',
8384
}
8485
DBOS(config=config)
8586
DBOS.launch()
8687
if resume_id is not None:
8788
print('resuming existing workflow', resume_id)
88-
wf_id = resume_id
89+
# Get the workflow handle and wait for the result
90+
wf_handle: WorkflowHandleAsync[AgentRunResult] = await DBOS.retrieve_workflow_async(resume_id)
91+
result = await wf_handle.get_result()
8992
else:
9093
wf_id = f'twenty-questions-{uuid.uuid4()}'
9194
print('starting new workflow', wf_id)
92-
93-
state = GameState(answer=answer)
94-
with SetWorkflowID(wf_id):
95-
result = await dbos_questioner_agent.run('start', deps=state, usage_limits=UsageLimits(request_limit=25))
95+
state = GameState(answer=answer)
96+
with SetWorkflowID(wf_id):
97+
result = await dbos_questioner_agent.run('start', deps=state, usage_limits=UsageLimits(request_limit=25))
9698

9799
print(f'After {len(result.all_messages()) / 2}, the answer is: {result.output}')
98100

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies = [
1212
"mcp>=1.15.0",
1313
"pydantic-ai>=1",
1414
"tavily-python>=0.7.12",
15-
"dbos>=2",
15+
"dbos>=2.4.0",
1616
]
1717

1818
[dependency-groups]

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)