Skip to content

Commit

Permalink
fix(agents-api): Update TODO stuff
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr committed Dec 26, 2024
1 parent d5a9106 commit f0deed9
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 46 deletions.
2 changes: 0 additions & 2 deletions agents-api/agents_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@

with workflow.unsafe.imports_passed_through():
import msgpack as msgpack

import os
7 changes: 2 additions & 5 deletions agents-api/agents_api/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from contextlib import asynccontextmanager
from typing import Any, Callable, Coroutine

from aiobotocore.session import get_session
from fastapi import APIRouter, FastAPI, Request, Response
from fastapi.params import Depends
from fastapi import APIRouter, FastAPI
from prometheus_fastapi_instrumentator import Instrumentator
from scalar_fastapi import get_scalar_api_reference

from .clients.pg import create_db_pool
from .dependencies.content_length import valid_content_length
from .env import api_prefix, hostname, max_payload_size, protocol, public_port
from .env import api_prefix, hostname, protocol, public_port


# TODO: This currently doesn't use .env variables, but we should move to using them
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Literal
from typing import Literal
from uuid import UUID

import asyncpg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Annotated, Any, TypeVar
from typing import Annotated
from uuid import UUID

import asyncpg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
""").sql(pretty=True)


# FIXME: Remove this function
def validate_transition_targets(data: CreateTransitionRequest) -> None:
# Make sure the current/next targets are valid
match data.type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
@beartype
async def create_temporal_lookup(
*,
developer_id: UUID, # TODO: what to do with this parameter?
developer_id: UUID, # FIXME: Remove this parameter
execution_id: UUID,
workflow_handle: WorkflowHandle,
) -> tuple[str, list]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Literal, TypeVar
from typing import Literal
from uuid import UUID

import asyncpg
Expand All @@ -14,6 +14,7 @@
wrap_in_class,
)

# FIXME: Use latest_transitions instead of transitions
# Query to get an execution transition
get_execution_transition_query = parse_one("""
SELECT * FROM transitions
Expand Down Expand Up @@ -59,7 +60,7 @@ def _transform(d):
@beartype
async def get_execution_transition(
*,
developer_id: UUID, # TODO: what to do with this parameter?
developer_id: UUID, # FIXME: Remove this parameter
transition_id: UUID | None = None,
task_token: str | None = None,
) -> tuple[str, list, Literal["fetch", "fetchmany", "fetchrow"]]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from typing import Any, Literal, TypeVar
from typing import Literal
from uuid import UUID

import asyncpg
from beartype import beartype
from fastapi import HTTPException
from sqlglot import parse_one

from ..utils import (
partialclass,
Expand All @@ -14,14 +13,14 @@
)

# Query to get a paused execution token
get_paused_execution_token_query = parse_one("""
SELECT * FROM transitions
get_paused_execution_token_query = """
SELECT * FROM latest_transitions
WHERE
execution_id = $1
AND type = 'wait'
ORDER BY created_at DESC
LIMIT 1;
""").sql(pretty=True)
"""


@rewrap_exceptions(
Expand Down Expand Up @@ -53,20 +52,6 @@ async def get_paused_execution_token(
"""
execution_id = str(execution_id)

# TODO: what to do with this query?
# check_status_query = """
# ?[execution_id, status] :=
# *executions:execution_id_status_idx {
# execution_id,
# status,
# },
# execution_id = to_uuid($execution_id),
# status = "awaiting_input"

# :limit 1
# :assert some
# """

return (
get_paused_execution_token_query,
[execution_id],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Literal, TypeVar
from typing import Literal
from uuid import UUID

import asyncpg
Expand Down
19 changes: 14 additions & 5 deletions agents-api/agents_api/queries/executions/lookup_temporal_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Literal, TypeVar
from typing import Literal
from uuid import UUID

import asyncpg
Expand All @@ -8,11 +8,20 @@

from ..utils import partialclass, pg_query, rewrap_exceptions, wrap_in_class

# FIXME: Check if this query is correct


# Query to lookup temporal data
lookup_temporal_data_query = parse_one("""
SELECT * FROM temporal_executions_lookup
SELECT t.*
FROM
temporal_executions_lookup t,
executions e
WHERE
execution_id = $1
t.execution_id = e.execution_id
AND t.developer_id = e.developer_id
AND e.execution_id = $1
AND e.developer_id = $2
LIMIT 1;
""").sql(pretty=True)

Expand All @@ -31,7 +40,7 @@
@beartype
async def lookup_temporal_data(
*,
developer_id: UUID, # TODO: what to do with this parameter?
developer_id: UUID,
execution_id: UUID,
) -> tuple[str, list, Literal["fetch", "fetchmany", "fetchrow"]]:
"""
Expand All @@ -49,6 +58,6 @@ async def lookup_temporal_data(

return (
lookup_temporal_data_query,
[execution_id],
[execution_id, developer_id],
"fetchrow",
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import Any
from uuid import UUID

from beartype import beartype
Expand Down
6 changes: 0 additions & 6 deletions agents-api/agents_api/routers/docs/create_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@

from fastapi import BackgroundTasks, Depends
from starlette.status import HTTP_201_CREATED
from temporalio.client import Client as TemporalClient
from uuid_extensions import uuid7

from ...activities.types import EmbedDocsPayload
from ...autogen.openapi_model import CreateDocRequest, Doc, ResourceCreatedResponse
from ...clients import temporal
from ...common.retry_policies import DEFAULT_RETRY_POLICY
from ...dependencies.developer_id import get_developer_id
from ...env import temporal_task_queue, testing
from ...queries.docs.create_doc import create_doc as create_doc_query
from .router import router

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
CreateTransitionRequest,
Execution,
ResourceCreatedResponse,
UpdateExecutionRequest,
)
from ...clients.temporal import run_task_execution_workflow
from ...common.protocol.developers import Developer
Expand Down
1 change: 0 additions & 1 deletion agents-api/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
from agents_api.queries.sessions.create_session import create_session
from agents_api.queries.tasks.create_task import create_task
from agents_api.queries.tools.create_tools import create_tools
from agents_api.queries.tools.delete_tool import delete_tool
from agents_api.queries.users.create_user import create_user
from agents_api.web import app

Expand Down

0 comments on commit f0deed9

Please sign in to comment.