Skip to content

Commit

Permalink
fix(agents-api): pytype fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr committed Oct 18, 2024
1 parent 25f36bd commit 3053335
Show file tree
Hide file tree
Showing 5 changed files with 302 additions and 216 deletions.
4 changes: 3 additions & 1 deletion agents-api/agents_api/activities/execute_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
from ..routers.docs.search_docs import search_agent_docs, search_user_docs


# FIXME: This is a total mess. Should be refactored.

@auto_blob_store
@beartype
async def execute_system(
context: StepContext,
system: SystemDef,
) -> Any:
arguments = system.arguments
arguments: dict[str, Any] = system.arguments or {}
arguments["developer_id"] = context.execution_input.developer_id

# Unbox all the arguments
Expand Down
10 changes: 7 additions & 3 deletions agents-api/agents_api/common/protocol/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def __save_item(self, item: Any) -> Any:

return store_in_blob_store_if_large(item)

def __getitem__(self, index: int | slice) -> Any:
def __getitem__(
self, index: int | slice
) -> Any: # pytype: disable=signature-mismatch
if isinstance(index, slice):
# Obtain the slice without triggering __getitem__ recursively
sliced_items = super().__getitem__(
Expand Down Expand Up @@ -162,7 +164,9 @@ def _extend_without_processing(self, items: list[Any]) -> None:
"""
super().extend(items)

def __setitem__(self, index: int | slice, value: Any) -> None:
def __setitem__(
self, index: int | slice, value: Any
) -> None: # pytype: disable=signature-mismatch
if isinstance(index, slice):
# Handle slice assignment without processing existing RemoteObjects
processed_values = [self.__save_item(v) for v in value]
Expand Down Expand Up @@ -231,7 +235,7 @@ def extend(self, iterable: list[Any]) -> None:
for item in iterable:
self.append(item)

def __iter__(self) -> Iterator[Any]:
def __iter__(self) -> Iterator[Any]: # pytype: disable=signature-mismatch
for index in range(len(self)):
yield self.__getitem__(index)

Expand Down
4 changes: 2 additions & 2 deletions agents-api/agents_api/common/storage_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def load_from_blob_store_if_remote(x: Any | RemoteObject) -> Any:
def auto_blob_store(f: Callable | None = None, *, deep: bool = False) -> Callable:
def auto_blob_store_decorator(f: Callable) -> Callable:
def load_args(
args: list[Any], kwargs: dict[str, Any]
) -> tuple[list[Any], dict[str, Any]]:
args: list | tuple, kwargs: dict[str, Any]
) -> tuple[list | tuple, dict[str, Any]]:
new_args = [load_from_blob_store_if_remote(arg) for arg in args]
new_kwargs = {
k: load_from_blob_store_if_remote(v) for k, v in kwargs.items()
Expand Down
Loading

0 comments on commit 3053335

Please sign in to comment.