From eed882776bdcd39a20f32dfadcdf7eec3e7efc5f Mon Sep 17 00:00:00 2001 From: "ellipsis-dev[bot]" <65095814+ellipsis-dev[bot]@users.noreply.github.com> Date: Fri, 27 Dec 2024 02:35:48 +0000 Subject: [PATCH] address comments left by @creatorrr on #986 (feat(agents-api): Configure routes ); --- .../activities/task_steps/__init__.py | 2 -- .../activities/task_steps/cozo_query_step.py | 28 ------------------- agents-api/agents_api/common/utils/cozo.py | 26 ----------------- agents-api/agents_api/env.py | 4 --- .../agents_api/models/agent/create_agent.py | 3 -- .../models/agent/create_or_update_agent.py | 3 -- .../agents_api/models/agent/delete_agent.py | 2 -- .../agents_api/models/agent/get_agent.py | 2 -- .../agents_api/models/agent/list_agents.py | 2 -- .../agents_api/models/agent/patch_agent.py | 3 -- .../agents_api/models/agent/update_agent.py | 3 -- .../agents_api/models/docs/create_doc.py | 3 -- 12 files changed, 81 deletions(-) diff --git a/agents-api/agents_api/activities/task_steps/__init__.py b/agents-api/agents_api/activities/task_steps/__init__.py index 482fc42da..79fac8a2c 100644 --- a/agents-api/agents_api/activities/task_steps/__init__.py +++ b/agents-api/agents_api/activities/task_steps/__init__.py @@ -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 diff --git a/agents-api/agents_api/activities/task_steps/cozo_query_step.py b/agents-api/agents_api/activities/task_steps/cozo_query_step.py index 8d28d83c9..e69de29bb 100644 --- a/agents-api/agents_api/activities/task_steps/cozo_query_step.py +++ b/agents-api/agents_api/activities/task_steps/cozo_query_step.py @@ -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 -) diff --git a/agents-api/agents_api/common/utils/cozo.py b/agents-api/agents_api/common/utils/cozo.py index f342ba617..e69de29bb 100644 --- a/agents-api/agents_api/common/utils/cozo.py +++ b/agents-api/agents_api/common/utils/cozo.py @@ -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])) diff --git a/agents-api/agents_api/env.py b/agents-api/agents_api/env.py index 54c8a2eee..d8f3d5d9f 100644 --- a/agents-api/agents_api/env.py +++ b/agents-api/agents_api/env.py @@ -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" ) @@ -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, diff --git a/agents-api/agents_api/models/agent/create_agent.py b/agents-api/agents_api/models/agent/create_agent.py index 1872a6f36..6595fac68 100644 --- a/agents-api/agents_api/models/agent/create_agent.py +++ b/agents-api/agents_api/models/agent/create_agent.py @@ -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, diff --git a/agents-api/agents_api/models/agent/create_or_update_agent.py b/agents-api/agents_api/models/agent/create_or_update_agent.py index 9a1feb717..2a6c3a6f0 100644 --- a/agents-api/agents_api/models/agent/create_or_update_agent.py +++ b/agents-api/agents_api/models/agent/create_or_update_agent.py @@ -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, diff --git a/agents-api/agents_api/models/agent/delete_agent.py b/agents-api/agents_api/models/agent/delete_agent.py index 60de66292..ba143f8a1 100644 --- a/agents-api/agents_api/models/agent/delete_agent.py +++ b/agents-api/agents_api/models/agent/delete_agent.py @@ -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, diff --git a/agents-api/agents_api/models/agent/get_agent.py b/agents-api/agents_api/models/agent/get_agent.py index 008e39454..bd625e053 100644 --- a/agents-api/agents_api/models/agent/get_agent.py +++ b/agents-api/agents_api/models/agent/get_agent.py @@ -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, diff --git a/agents-api/agents_api/models/agent/list_agents.py b/agents-api/agents_api/models/agent/list_agents.py index 882b6c8c6..696d086be 100644 --- a/agents-api/agents_api/models/agent/list_agents.py +++ b/agents-api/agents_api/models/agent/list_agents.py @@ -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, diff --git a/agents-api/agents_api/models/agent/patch_agent.py b/agents-api/agents_api/models/agent/patch_agent.py index 99d4e3553..6dd0d25e4 100644 --- a/agents-api/agents_api/models/agent/patch_agent.py +++ b/agents-api/agents_api/models/agent/patch_agent.py @@ -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, diff --git a/agents-api/agents_api/models/agent/update_agent.py b/agents-api/agents_api/models/agent/update_agent.py index b36f687eb..fd0c54681 100644 --- a/agents-api/agents_api/models/agent/update_agent.py +++ b/agents-api/agents_api/models/agent/update_agent.py @@ -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, diff --git a/agents-api/agents_api/models/docs/create_doc.py b/agents-api/agents_api/models/docs/create_doc.py index ceb8b5fe0..53b79d3f2 100644 --- a/agents-api/agents_api/models/docs/create_doc.py +++ b/agents-api/agents_api/models/docs/create_doc.py @@ -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,