-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e630a55
commit 6f9dab5
Showing
25 changed files
with
779 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
from uuid import UUID | ||
|
||
from ..utils import cozo_query | ||
from typing import Literal, Dict, Any | ||
|
||
from beartype import beartype | ||
|
||
|
||
@cozo_query | ||
def create_execution_query( | ||
@beartype | ||
def get_execution_query( | ||
task_id: UUID, | ||
execution_id: UUID, | ||
status: Literal[ | ||
"queued", "starting", "running", "waiting-for-input", "success", "failed" | ||
] = "queued", | ||
arguments: Dict[str, Any] = {}, | ||
) -> tuple[str, dict]: | ||
query = """""" | ||
query = """ | ||
{ | ||
?[status, arguments, created_at, updated_at] := *executions { | ||
task_id: to_uuid($task_id), | ||
execution_id: to_uuid($execution_id), | ||
status, | ||
arguments, | ||
created_at, | ||
updated_at, | ||
} | ||
} | ||
""" | ||
return ( | ||
query, | ||
{ | ||
"task_id": str(task_id), | ||
"execution_id": str(execution_id), | ||
"status": status, | ||
"arguments": arguments, | ||
}, | ||
) |
19 changes: 14 additions & 5 deletions
19
agents-api/agents_api/models/execution/get_execution_status.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
from typing import Literal | ||
from uuid import UUID | ||
from beartype import beartype | ||
|
||
from ..utils import cozo_query | ||
|
||
|
||
@cozo_query | ||
def get_execution_status_query(task_id: UUID, developer_id: UUID) -> tuple[str, dict]: | ||
@beartype | ||
def get_execution_status_query(task_id: UUID, execution_id: UUID) -> tuple[str, dict]: | ||
task_id = str(task_id) | ||
developer_id = str(developer_id) | ||
query = """""" | ||
return (query, {"task_id": task_id, "developer_id": developer_id}) | ||
execution_id = str(execution_id) | ||
query = """ | ||
{ | ||
?[status] := *executions { | ||
task_id: to_uuid($task_id), | ||
execution_id: to_uuid($execution_id), | ||
status, | ||
} | ||
} | ||
""" | ||
return (query, {"task_id": task_id, "execution_id": execution_id}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from uuid import UUID | ||
|
||
from beartype import beartype | ||
|
||
from ..utils import cozo_query | ||
|
||
|
||
@cozo_query | ||
@beartype | ||
def list_task_executions_query( | ||
agent_id: UUID, task_id: UUID, developer_id: UUID | ||
) -> tuple[str, dict]: | ||
# TODO: Check for agent in developer ID; Assert whether dev can access agent and by relation the task | ||
query = """ | ||
{ | ||
?[ | ||
execution_id, | ||
status, | ||
arguments, | ||
created_at, | ||
updated_at, | ||
] := *executions { | ||
task_id: to_uuid($task_id), | ||
execution_id, | ||
status, | ||
arguments, | ||
created_at, | ||
updated_at, | ||
} | ||
:limit 10 | ||
:offset 0 | ||
} | ||
""" | ||
return (query, {"task_id": str(task_id)}) |
25 changes: 0 additions & 25 deletions
25
agents-api/agents_api/models/execution/update_execution.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 32 additions & 4 deletions
36
agents-api/agents_api/models/execution/update_execution_transition.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,47 @@ | ||
from uuid import UUID | ||
|
||
from agents_api.common.utils.datetime import utcnow | ||
|
||
from ..utils import cozo_query | ||
from ...common.utils.cozo import cozo_process_mutate_data | ||
|
||
|
||
@cozo_query | ||
def get_execution_transition_query( | ||
execution_id: UUID, transition_id: UUID, developer_id: UUID | ||
def update_execution_transition_query( | ||
execution_id: UUID, transition_id: UUID, **update_data | ||
) -> tuple[str, dict]: | ||
|
||
query = """""" | ||
transition_update_cols, transition_update_vals = cozo_process_mutate_data( | ||
{ | ||
**{k: v for k, v, in update_data.items() if v is not None}, | ||
"execution_id": str(execution_id), | ||
"transition_id": str(transition_id), | ||
"updated_at": utcnow().timestamp(), | ||
} | ||
) | ||
query = f""" | ||
{{ | ||
input[{transition_update_cols}] <- $transition_update_vals | ||
?[{transition_update_cols}] := input[{transition_update_cols}], | ||
*transitions {{ | ||
execution_id: to_uuid($execution_id), | ||
transition_id: to_uuid($transition_id), | ||
}} | ||
:update transitions {{ | ||
{transition_update_cols} | ||
}} | ||
:returning | ||
}} | ||
""" | ||
|
||
return ( | ||
query, | ||
{ | ||
"transitioon_update_vals": transition_update_vals, | ||
"execution_id": str(execution_id), | ||
"transition_id": str(transition_id), | ||
"developer_id": str(developer_id), | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.