Skip to content

Commit

Permalink
refactor: Lint agents-api (CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedantsahai18 authored and github-actions[bot] committed Dec 25, 2024
1 parent eaada88 commit 88ca072
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 107 deletions.
1 change: 0 additions & 1 deletion agents-api/agents_api/queries/executions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from .lookup_temporal_data import lookup_temporal_data
from .prepare_execution_input import prepare_execution_input


__all__ = [
"count_executions",
"create_execution",
Expand Down
31 changes: 16 additions & 15 deletions agents-api/agents_api/queries/executions/count_executions.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import Any, Literal
from uuid import UUID

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

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

# Query to count executions for a given task
Expand All @@ -22,18 +23,18 @@


@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task"
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist"
),
}
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task",
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist",
),
}
)
@wrap_in_class(dict, one=True)
@pg_query
Expand Down
35 changes: 17 additions & 18 deletions agents-api/agents_api/queries/executions/create_execution.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
from typing import Annotated, Any, TypeVar
from uuid import UUID

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

from ...autogen.openapi_model import CreateExecutionRequest, Execution
from ...common.utils.datetime import utcnow
from ...common.utils.types import dict_like
from ...metrics.counters import increase_counter
from sqlglot import parse_one
import asyncpg
from fastapi import HTTPException
from ..utils import (
partialclass,
pg_query,
wrap_in_class,
rewrap_exceptions,
partialclass,
wrap_in_class,
)
from .constants import OUTPUT_UNNEST_KEY


create_execution_query = parse_one("""
INSERT INTO executions
(
Expand All @@ -44,18 +43,18 @@


@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task"
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist"
),
}
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task",
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist",
),
}
)
@wrap_in_class(
Execution,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from typing import Literal
from uuid import UUID

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

from ...autogen.openapi_model import (
CreateTransitionRequest,
Transition,
)
import asyncpg
from fastapi import HTTPException
from sqlglot import parse_one
from ...common.utils.datetime import utcnow
from ...metrics.counters import increase_counter
from ..utils import (
partialclass,
pg_query,
wrap_in_class,
rewrap_exceptions,
partialclass,
wrap_in_class,
)

# Query to create a transition
Expand Down Expand Up @@ -87,18 +87,18 @@ def validate_transition_targets(data: CreateTransitionRequest) -> None:


@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task"
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist"
),
}
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task",
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist",
),
}
)
@wrap_in_class(
Transition,
Expand Down
34 changes: 17 additions & 17 deletions agents-api/agents_api/queries/executions/create_temporal_lookup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from uuid import UUID

from beartype import beartype
from temporalio.client import WorkflowHandle
from sqlglot import parse_one
import asyncpg
from beartype import beartype
from fastapi import HTTPException
from uuid import UUID
from sqlglot import parse_one
from temporalio.client import WorkflowHandle

from ...metrics.counters import increase_counter
from ..utils import (
partialclass,
pg_query,
rewrap_exceptions,
partialclass,
)

# Query to create a temporal lookup
Expand All @@ -36,18 +36,18 @@


@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task"
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist"
),
}
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task",
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist",
),
}
)
@pg_query
@increase_counter("create_temporal_lookup")
Expand Down
6 changes: 3 additions & 3 deletions agents-api/agents_api/queries/executions/get_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from uuid import UUID

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

from ...autogen.openapi_model import Execution
from ..utils import (
Expand All @@ -27,9 +27,9 @@
@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
HTTPException,
status_code=404,
detail="No executions found for the specified task"
detail="No executions found for the specified task",
),
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from beartype import beartype
from fastapi import HTTPException
from sqlglot import parse_one

from ...autogen.openapi_model import Transition
from ..utils import (
partialclass,
Expand Down Expand Up @@ -40,18 +41,18 @@ def _transform(d):


@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task"
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist"
),
}
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
status_code=404,
detail="No executions found for the specified task",
),
asyncpg.ForeignKeyViolationError: partialclass(
HTTPException,
status_code=404,
detail="The specified developer or task does not exist",
),
}
)
@wrap_in_class(Transition, one=True, transform=_transform)
@pg_query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
HTTPException,
status_code=404,
detail="No paused executions found for the specified task"
detail="No paused executions found for the specified task",
),
}
)
Expand Down Expand Up @@ -72,4 +72,3 @@ async def get_paused_execution_token(
[execution_id],
"fetchrow",
)

Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
HTTPException,
status_code=404,
detail="No temporal workflow data found for the specified execution"
detail="No temporal workflow data found for the specified execution",
),
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@ def _transform(d):
@rewrap_exceptions(
{
asyncpg.InvalidRowCountInLimitClauseError: partialclass(
HTTPException,
status_code=400,
detail="Invalid limit clause"
HTTPException, status_code=400, detail="Invalid limit clause"
),
asyncpg.InvalidRowCountInResultOffsetClauseError: partialclass(
HTTPException,
status_code=400,
detail="Invalid offset clause"
HTTPException, status_code=400, detail="Invalid offset clause"
),
}
)
Expand Down
9 changes: 3 additions & 6 deletions agents-api/agents_api/queries/executions/list_executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from beartype import beartype
from fastapi import HTTPException
from sqlglot import parse_one

from ...autogen.openapi_model import Execution
from ..utils import (
partialclass,
Expand Down Expand Up @@ -32,14 +33,10 @@
@rewrap_exceptions(
{
asyncpg.InvalidRowCountInLimitClauseError: partialclass(
HTTPException,
status_code=400,
detail="Invalid limit clause"
HTTPException, status_code=400, detail="Invalid limit clause"
),
asyncpg.InvalidRowCountInResultOffsetClauseError: partialclass(
HTTPException,
status_code=400,
detail="Invalid offset clause"
HTTPException, status_code=400, detail="Invalid offset clause"
),
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from beartype import beartype
from fastapi import HTTPException
from sqlglot import parse_one

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

# Query to lookup temporal data
Expand All @@ -19,9 +20,9 @@
@rewrap_exceptions(
{
asyncpg.NoDataFoundError: partialclass(
HTTPException,
HTTPException,
status_code=404,
detail="No temporal data found for the specified execution"
detail="No temporal data found for the specified execution",
),
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from beartype import beartype
from sqlglot import parse_one

from ...common.protocol.tasks import ExecutionInput
from ..utils import (
pg_query,
Expand Down
Loading

0 comments on commit 88ca072

Please sign in to comment.