Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Handling of WorkflowDone exception #17047

Merged
merged 2 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llama-index-core/llama_index/core/workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ async def _task(
try:
new_ev = await instrumented_step(**kwargs)
break # exit the retrying loop
except WorkflowDone:
raise
except Exception as e:
if config.retry_policy is None:
raise WorkflowRuntimeError(
Expand Down Expand Up @@ -256,6 +258,8 @@ async def _task(
new_ev = await asyncio.get_event_loop().run_in_executor(
None, run_task
)
except WorkflowDone:
raise
except Exception as e:
raise WorkflowRuntimeError(
f"Error in step '{name}': {e!s}"
Expand Down
4 changes: 3 additions & 1 deletion llama-index-core/tests/workflow/test_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ async def step(self, ctx: Context, ev: StartEvent) -> StopEvent:
assert ev.test_param == "foo"

# Make sure the await actually caught the exception
with pytest.raises(ValueError, match="The step raised an error!"):
with pytest.raises(
WorkflowRuntimeError, match="Error in step 'step': The step raised an error!"
):
await r


Expand Down
8 changes: 6 additions & 2 deletions llama-index-core/tests/workflow/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ async def step(self, ev: StartEvent) -> StopEvent:
raise ValueError("The step raised an error!")

workflow = DummyWorkflow()
with pytest.raises(ValueError, match="The step raised an error!"):
with pytest.raises(
WorkflowRuntimeError, match="Error in step 'step': The step raised an error!"
):
await workflow.run()


Expand All @@ -418,7 +420,9 @@ async def step(self, ev: StartEvent) -> StopEvent:
raise ValueError("The step raised an error!")

workflow = DummyWorkflow()
with pytest.raises(ValueError, match="The step raised an error!"):
with pytest.raises(
WorkflowRuntimeError, match="Error in step 'step': The step raised an error!"
):
handler = workflow.run(stepwise=True)
await handler.run_step()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ exclude = ["**/BUILD"]
license = "MIT"
name = "llama-index-embeddings-nebius"
readme = "README.md"
version = "0.3.0"
version = "0.3.1"

[tool.poetry.dependencies]
python = ">=3.9,<4.0"
llama-index-core = "^0.12.0"
llama-index-embeddings-openai = "^0.3.0"

[tool.poetry.group.dev.dependencies]
ipython = "8.10.0"
Expand Down
Loading