From 993a45596afa835f34f374023f3fbfa440b3facb Mon Sep 17 00:00:00 2001 From: Abram Date: Thu, 14 Dec 2023 11:02:02 +0100 Subject: [PATCH] Update - modified execute_function to make use of time.perf_counter and also cleanup imports and entrypoint function --- agenta-cli/agenta/sdk/agenta_decorator.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/agenta-cli/agenta/sdk/agenta_decorator.py b/agenta-cli/agenta/sdk/agenta_decorator.py index 9a34ccaaa1..58646b2e21 100644 --- a/agenta-cli/agenta/sdk/agenta_decorator.py +++ b/agenta-cli/agenta/sdk/agenta_decorator.py @@ -8,7 +8,7 @@ import functools from pathlib import Path from tempfile import NamedTemporaryFile -from typing import Any, Callable, Dict, Optional, Tuple, List, TypeVar +from typing import Any, Callable, Dict, Optional, Tuple, List, Union from fastapi import Body, FastAPI, UploadFile from fastapi.responses import JSONResponse @@ -31,7 +31,6 @@ ) app = FastAPI() -T = TypeVar("T") origins = [ "*", @@ -55,7 +54,7 @@ def ingest_file(upfile: UploadFile): return InFile(file_name=upfile.filename, file_path=temp_file.name) -def entrypoint(func: Callable[..., T]) -> Callable[..., Dict[str, T]]: +def entrypoint(func: Callable[..., Any]) -> Callable[..., Any]: """ Decorator to wrap a function for HTTP POST and terminal exposure. @@ -151,7 +150,7 @@ def ingest_files( func_params[name] = ingest_file(func_params[name]) -async def execute_function(func: Callable[..., Any], *args, **func_params) -> Any: +async def execute_function(func: Callable[..., Any], *args, **func_params) -> Union[Dict[str, Any], JSONResponse]: """Execute the function and handle any exceptions.""" try: