From 9f85faaf2472110f01cbd492989c1c916dd2ce44 Mon Sep 17 00:00:00 2001 From: Evan Doyle Date: Fri, 23 Aug 2024 15:39:06 -0700 Subject: [PATCH] Fix deploy bug in service registration; fix silent json status errors from lambda invoke --- pkg/pare/cli/deploy.py | 2 +- pkg/pare/sdk/main.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/pare/cli/deploy.py b/pkg/pare/cli/deploy.py index e42f048..8a6469d 100644 --- a/pkg/pare/cli/deploy.py +++ b/pkg/pare/cli/deploy.py @@ -99,7 +99,7 @@ def register_services(self) -> list[ServiceConfig]: module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) for name, obj in inspect.getmembers(module): - if inspect.isfunction(obj) and hasattr(obj, "_pare_register"): + if callable(obj) and hasattr(obj, "_pare_register"): try: service_registration = cast( ServiceRegistration, diff --git a/pkg/pare/sdk/main.py b/pkg/pare/sdk/main.py index c75cdd3..873d02d 100644 --- a/pkg/pare/sdk/main.py +++ b/pkg/pare/sdk/main.py @@ -28,6 +28,11 @@ def invoke_endpoint(function_name: str, arguments: RemoteInvocationArguments) -> ) response.raise_for_status() json_response = response.json() + json_status = json_response.get("status", 500) + if json_status != 200: + raise errors.PareInvokeError( + f"Function invocation for '{function_name}' failed with status: {json_status}. Detail: {json_response.get('detail', '[No detail provided]')}" + ) return json_response.get("result") except requests.HTTPError as e: raise errors.PareInvokeError( @@ -51,6 +56,11 @@ async def async_invoke_endpoint( ) as response: response.raise_for_status() json_response = await response.json() + json_status = json_response.get("status", 500) + if json_status != 200: + raise errors.PareInvokeError( + f"Function invocation for '{function_name}' failed with status: {json_status}. Detail: {json_response.get('detail', '[No detail provided]')}" + ) return json_response.get("result") except aiohttp.ClientResponseError as e: raise errors.PareInvokeError(