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

[Ellipsis] refactor: move execution queries and add new routes and tests #997

Closed
Closed
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
2 changes: 0 additions & 2 deletions agents-api/agents_api/activities/task_steps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# ruff: noqa: F401, F403, F405

from .base_evaluate import base_evaluate

# from .cozo_query_step import cozo_query_step
from .evaluate_step import evaluate_step
from .for_each_step import for_each_step
from .get_value_step import get_value_step
Expand Down
28 changes: 0 additions & 28 deletions agents-api/agents_api/activities/task_steps/cozo_query_step.py
Original file line number Diff line number Diff line change
@@ -1,28 +0,0 @@
from typing import Any

from beartype import beartype
from temporalio import activity

from ... import models
from ...env import testing


@beartype
async def cozo_query_step(
query_name: str,
values: dict[str, Any],
) -> Any:
(module_name, name) = query_name.split(".")

module = getattr(models, module_name)
query = getattr(module, name)
return query(**values)


# Note: This is here just for clarity. We could have just imported cozo_query_step directly
# They do the same thing, so we dont need to mock the cozo_query_step function
mock_cozo_query_step = cozo_query_step

cozo_query_step = activity.defn(name="cozo_query_step")(
cozo_query_step if not testing else mock_cozo_query_step
)
26 changes: 0 additions & 26 deletions agents-api/agents_api/common/utils/cozo.py
Original file line number Diff line number Diff line change
@@ -1,26 +0,0 @@
#!/usr/bin/env python3

"""This module provides utility functions for interacting with the Cozo API client, including data mutation processes."""

from types import SimpleNamespace
from uuid import UUID

from beartype import beartype
from pycozo import Client

# Define a mock client for testing purposes, simulating Cozo API client behavior.
_fake_client: SimpleNamespace = SimpleNamespace()
# Lambda function to process and mutate data dictionaries using the Cozo client's internal method. This is a workaround to access protected member functions for testing.
_fake_client._process_mutate_data_dict = lambda data: (
Client._process_mutate_data_dict(_fake_client, data)
)

# Public interface to process and mutate data using the Cozo client. It wraps the client's internal processing method for external use.
cozo_process_mutate_data = _fake_client._process_mutate_data = lambda data: (
Client._process_mutate_data(_fake_client, data)
)


@beartype
def uuid_int_list_to_uuid(data: list[int]) -> UUID:
return UUID(bytes=b"".join([i.to_bytes(1, "big") for i in data]))
4 changes: 0 additions & 4 deletions agents-api/agents_api/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@

# Cozo
# ----
cozo_host: str = env.str("COZO_HOST", default="http://127.0.0.1:9070")
cozo_auth: str = env.str("COZO_AUTH_TOKEN", default=None)
summarization_model_name: str = env.str(
"SUMMARIZATION_MODEL_NAME", default="gpt-4-turbo"
)
Expand Down Expand Up @@ -156,8 +154,6 @@ def _parse_optional_int(val: str | None) -> int | None:
environment: Dict[str, Any] = dict(
debug=debug,
multi_tenant_mode=multi_tenant_mode,
cozo_host=cozo_host,
cozo_auth=cozo_auth,
sentry_dsn=sentry_dsn,
temporal_endpoint=temporal_endpoint,
temporal_task_queue=temporal_task_queue,
Expand Down
3 changes: 0 additions & 3 deletions agents-api/agents_api/models/agent/create_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@

from beartype import beartype
from fastapi import HTTPException
from pycozo.client import QueryException
from pydantic import ValidationError
from uuid_extensions import uuid7

from ...autogen.openapi_model import Agent, CreateAgentRequest
from ...common.utils.cozo import cozo_process_mutate_data
from ...metrics.counters import increase_counter
from ..utils import (
cozo_query,
partialclass,
rewrap_exceptions,
verify_developer_id_query,
Expand Down
3 changes: 0 additions & 3 deletions agents-api/agents_api/models/agent/create_or_update_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@

from beartype import beartype
from fastapi import HTTPException
from pycozo.client import QueryException
from pydantic import ValidationError

from ...autogen.openapi_model import Agent, CreateOrUpdateAgentRequest
from ...common.utils.cozo import cozo_process_mutate_data
from ...metrics.counters import increase_counter
from ..utils import (
cozo_query,
partialclass,
rewrap_exceptions,
verify_developer_id_query,
Expand Down
2 changes: 0 additions & 2 deletions agents-api/agents_api/models/agent/delete_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

from beartype import beartype
from fastapi import HTTPException
from pycozo.client import QueryException
from pydantic import ValidationError

from ...autogen.openapi_model import ResourceDeletedResponse
from ...common.utils.datetime import utcnow
from ..utils import (
cozo_query,
partialclass,
rewrap_exceptions,
verify_developer_id_query,
Expand Down
2 changes: 0 additions & 2 deletions agents-api/agents_api/models/agent/get_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

from beartype import beartype
from fastapi import HTTPException
from pycozo.client import QueryException
from pydantic import ValidationError

from ...autogen.openapi_model import Agent
from ..utils import (
cozo_query,
partialclass,
rewrap_exceptions,
verify_developer_id_query,
Expand Down
2 changes: 0 additions & 2 deletions agents-api/agents_api/models/agent/list_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

from beartype import beartype
from fastapi import HTTPException
from pycozo.client import QueryException
from pydantic import ValidationError

from ...autogen.openapi_model import Agent
from ...common.utils import json
from ..utils import (
cozo_query,
partialclass,
rewrap_exceptions,
verify_developer_id_query,
Expand Down
3 changes: 0 additions & 3 deletions agents-api/agents_api/models/agent/patch_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@

from beartype import beartype
from fastapi import HTTPException
from pycozo.client import QueryException
from pydantic import ValidationError

from ...autogen.openapi_model import PatchAgentRequest, ResourceUpdatedResponse
from ...common.utils.cozo import cozo_process_mutate_data
from ...common.utils.datetime import utcnow
from ...metrics.counters import increase_counter
from ..utils import (
cozo_query,
partialclass,
rewrap_exceptions,
verify_developer_id_query,
Expand Down
3 changes: 0 additions & 3 deletions agents-api/agents_api/models/agent/update_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@

from beartype import beartype
from fastapi import HTTPException
from pycozo.client import QueryException
from pydantic import ValidationError

from ...autogen.openapi_model import ResourceUpdatedResponse, UpdateAgentRequest
from ...common.utils.cozo import cozo_process_mutate_data
from ...metrics.counters import increase_counter
from ..utils import (
cozo_query,
partialclass,
rewrap_exceptions,
verify_developer_id_query,
Expand Down
3 changes: 0 additions & 3 deletions agents-api/agents_api/models/docs/create_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@

from beartype import beartype
from fastapi import HTTPException
from pycozo.client import QueryException
from pydantic import ValidationError
from uuid_extensions import uuid7

from ...autogen.openapi_model import CreateDocRequest, Doc
from ...common.utils.cozo import cozo_process_mutate_data
from ...metrics.counters import increase_counter
from ..utils import (
cozo_query,
partialclass,
rewrap_exceptions,
verify_developer_id_query,
Expand Down
Loading