Skip to content

Commit

Permalink
fix: Fix get task
Browse files Browse the repository at this point in the history
  • Loading branch information
whiterabbit1983 committed Dec 26, 2024
1 parent 7011246 commit 1c4fbee
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
6 changes: 2 additions & 4 deletions agents-api/agents_api/common/protocol/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,8 @@ def spec_to_task_data(spec: dict) -> dict:
workflows = spec.pop("workflows")
workflows_dict = {workflow["name"]: workflow["steps"] for workflow in workflows}

tools = spec.pop("tools", [])
tools = [
{tool["type"]: tool.pop("spec"), **tool} for tool in tools if tool is not None
]
tools = spec.pop("tools", []) or []
tools = [{tool["type"]: tool.pop("spec"), **tool} for tool in tools if tool]

return {
"id": task_id,
Expand Down
84 changes: 43 additions & 41 deletions agents-api/tests/test_task_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
test_task,
test_transition,
)

from .fixtures import test_execution, test_transition
from .utils import patch_testing_temporal


Expand Down Expand Up @@ -136,19 +138,19 @@ def _(make_request=make_request, execution=test_execution, transition=test_trans
assert len(transitions) > 0


# @test("route: list task executions")
# def _(make_request=make_request, execution=test_execution):
# response = make_request(
# method="GET",
# url=f"/tasks/{str(execution.task_id)}/executions",
# )
@test("route: list task executions")
def _(make_request=make_request, execution=test_execution):
response = make_request(
method="GET",
url=f"/tasks/{str(execution.task_id)}/executions",
)

# assert response.status_code == 200
# response = response.json()
# executions = response["items"]
assert response.status_code == 200
response = response.json()
executions = response["items"]

# assert isinstance(executions, list)
# assert len(executions) > 0
assert isinstance(executions, list)
assert len(executions) > 0


@test("route: list tasks")
Expand Down Expand Up @@ -193,42 +195,42 @@ def _(make_request=make_request, agent=test_agent):

# FIXME: This test is failing

# @test("route: patch execution")
# async def _(make_request=make_request, task=test_task):
# data = dict(
# input={},
# metadata={},
# )
@test("route: patch execution")
async def _(make_request=make_request, task=test_task):
data = dict(
input={},
metadata={},
)

# async with patch_testing_temporal():
# response = make_request(
# method="POST",
# url=f"/tasks/{str(task.id)}/executions",
# json=data,
# )
async with patch_testing_temporal():
response = make_request(
method="POST",
url=f"/tasks/{str(task.id)}/executions",
json=data,
)

# execution = response.json()
execution = response.json()

# data = dict(
# status="running",
# )
data = dict(
status="running",
)

# response = make_request(
# method="PATCH",
# url=f"/tasks/{str(task.id)}/executions/{str(execution['id'])}",
# json=data,
# )
response = make_request(
method="PATCH",
url=f"/tasks/{str(task.id)}/executions/{str(execution['id'])}",
json=data,
)

# assert response.status_code == 200
assert response.status_code == 200

# execution_id = response.json()["id"]
execution_id = response.json()["id"]

# response = make_request(
# method="GET",
# url=f"/executions/{execution_id}",
# )
response = make_request(
method="GET",
url=f"/executions/{execution_id}",
)

# assert response.status_code == 200
# execution = response.json()
assert response.status_code == 200
execution = response.json()

# assert execution["status"] == "running"
assert execution["status"] == "running"

0 comments on commit 1c4fbee

Please sign in to comment.