Skip to content

Commit

Permalink
refactor: Lint agents-api (CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad-mtos authored and github-actions[bot] committed Dec 18, 2024
1 parent 1b7a022 commit db31801
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 32 deletions.
5 changes: 2 additions & 3 deletions agents-api/agents_api/queries/agents/create_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
from sqlglot import parse_one
from uuid_extensions import uuid7

from ...metrics.counters import increase_counter

from ...autogen.openapi_model import Agent, CreateAgentRequest
from ...metrics.counters import increase_counter
from ..utils import (
generate_canonical_name,
pg_query,
wrap_in_class,
rewrap_exceptions,
wrap_in_class,
)

ModelT = TypeVar("ModelT", bound=Any)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from ..utils import (
generate_canonical_name,
pg_query,
wrap_in_class,
rewrap_exceptions,
wrap_in_class,
)

ModelT = TypeVar("ModelT", bound=Any)
Expand Down
4 changes: 2 additions & 2 deletions agents-api/agents_api/queries/agents/delete_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from sqlglot import parse_one

from ...autogen.openapi_model import ResourceDeletedResponse
from ...metrics.counters import increase_counter
from ...common.utils.datetime import utcnow
from ...metrics.counters import increase_counter
from ..utils import (
pg_query,
wrap_in_class,
rewrap_exceptions,
wrap_in_class,
)

ModelT = TypeVar("ModelT", bound=Any)
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/queries/agents/get_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from ...metrics.counters import increase_counter
from ..utils import (
pg_query,
wrap_in_class,
rewrap_exceptions,
wrap_in_class,
)

raw_query = """
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/queries/agents/list_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from ...metrics.counters import increase_counter
from ..utils import (
pg_query,
wrap_in_class,
rewrap_exceptions,
wrap_in_class,
)

ModelT = TypeVar("ModelT", bound=Any)
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/queries/agents/patch_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from ...metrics.counters import increase_counter
from ..utils import (
pg_query,
wrap_in_class,
rewrap_exceptions,
wrap_in_class,
)

ModelT = TypeVar("ModelT", bound=Any)
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/queries/agents/update_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from ...metrics.counters import increase_counter
from ..utils import (
pg_query,
wrap_in_class,
rewrap_exceptions,
wrap_in_class,
)

ModelT = TypeVar("ModelT", bound=Any)
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/queries/developers/get_developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from ..utils import (
partialclass,
pg_query,
wrap_in_class,
rewrap_exceptions,
wrap_in_class,
)

# TODO: Add verify_developer
Expand Down
2 changes: 1 addition & 1 deletion agents-api/agents_api/queries/entries/create_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def add_entry_relations(
item.get("is_leaf", False), # $5
]
)

return [
(
session_exists_query,
Expand Down
5 changes: 1 addition & 4 deletions agents-api/agents_api/queries/entries/list_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,5 @@ async def list_entries(
[session_id, developer_id],
"fetchrow",
),
(
query,
entry_params
),
(query, entry_params),
]
8 changes: 6 additions & 2 deletions agents-api/agents_api/queries/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def prepare_pg_query_args(
batch.append(
(
"fetchrow",
AsyncPGFetchArgs(query=query, args=variables, timeout=query_timeout),
AsyncPGFetchArgs(
query=query, args=variables, timeout=query_timeout
),
)
)
case _:
Expand Down Expand Up @@ -173,7 +175,9 @@ async def wrapper(
print(*args)
print("%" * 100)

if method_name == "fetchrow" and (len(results) == 0 or results.get("bool") is None):
if method_name == "fetchrow" and (
len(results) == 0 or results.get("bool") is None
):
raise asyncpg.NoDataFoundError

end = timeit and time.perf_counter()
Expand Down
3 changes: 1 addition & 2 deletions agents-api/tests/test_entry_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
It verifies the functionality of adding, retrieving, and processing entries as defined in the schema.
"""

from uuid_extensions import uuid7

from fastapi import HTTPException
from uuid_extensions import uuid7
from ward import raises, test

from agents_api.autogen.openapi_model import CreateEntryRequest
Expand Down
1 change: 0 additions & 1 deletion agents-api/tests/test_messages_truncation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# from uuid_extensions import uuid7

# from ward import raises, test
Expand Down
22 changes: 11 additions & 11 deletions agents-api/tests/test_session_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@
from ward import raises, test

from agents_api.autogen.openapi_model import (
Session,
CreateSessionRequest,
CreateOrUpdateSessionRequest,
UpdateSessionRequest,
CreateSessionRequest,
PatchSessionRequest,
ResourceUpdatedResponse,
ResourceDeletedResponse,
ResourceUpdatedResponse,
Session,
UpdateSessionRequest,
)
from agents_api.clients.pg import create_db_pool
from agents_api.queries.sessions import (
count_sessions,
create_or_update_session,
create_session,
delete_session,
get_session,
list_sessions,
create_session,
create_or_update_session,
update_session,
patch_session,
delete_session,
update_session,
)
from tests.fixtures import (
pg_dsn,
test_developer_id,
test_developer,
test_user,
test_agent,
test_developer,
test_developer_id,
test_session,
test_user,
)


Expand Down

0 comments on commit db31801

Please sign in to comment.