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

feat(agents-api): Add retry policies to temporal workflows/activities #551

Merged
merged 12 commits into from
Oct 5, 2024
Next Next commit
Reformat: poe check
  • Loading branch information
HamadaSalhab committed Oct 2, 2024
commit 8c17e18014b6d04aac9ff2f95c7ad87bbfd6025b
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64

from temporalio import activity

from ...autogen.openapi_model import CreateTransitionRequest
Expand All @@ -11,10 +12,9 @@

@activity.defn
async def raise_complete_async(context: StepContext, output: StepOutcome) -> None:

activity_info = activity.info()

captured_token = base64.b64encode(activity_info.task_token).decode('ascii')
captured_token = base64.b64encode(activity_info.task_token).decode("ascii")
activity_id = activity_info.activity_id
workflow_run_id = activity_info.workflow_run_id
workflow_id = activity_info.workflow_id
Expand Down
8 changes: 6 additions & 2 deletions agents-api/agents_api/routers/tasks/update_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ async def update_execution(
workflow_id = token_data["metadata"].get("x-workflow-id", None)
if activity_id is None or run_id is None or workflow_id is None:
act_handle = temporal_client.get_async_activity_handle(
task_token=base64.b64decode(token_data["task_token"].encode('ascii')),
task_token=base64.b64decode(
token_data["task_token"].encode("ascii")
),
)

else:
Expand All @@ -59,6 +61,8 @@ async def update_execution(
try:
await act_handle.complete(data.input)
except Exception as e:
raise HTTPException(status_code=500, detail="Failed to resume execution")
raise HTTPException(
status_code=500, detail="Failed to resume execution"
)
case _:
raise HTTPException(status_code=400, detail="Invalid request data")