From 007706e02b066154991d9916480d1fdcb03bfedb Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Sun, 3 Aug 2025 09:50:46 +0530 Subject: [PATCH 1/3] changed outputs to support list --- python-sdk/exospherehost/node/BaseNode.py | 4 ++-- python-sdk/exospherehost/runtime.py | 7 ++++++- state-manager/app/models/executed_models.py | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/python-sdk/exospherehost/node/BaseNode.py b/python-sdk/exospherehost/node/BaseNode.py index 633f2833..3d6129d5 100644 --- a/python-sdk/exospherehost/node/BaseNode.py +++ b/python-sdk/exospherehost/node/BaseNode.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import Optional, Any +from typing import Optional, Any, List class BaseNode(ABC): @@ -8,7 +8,7 @@ def __init__(self, unique_name: Optional[str] = None): self.unique_name: Optional[str] = unique_name @abstractmethod - async def execute(self, inputs: dict[str, Any]) -> dict[str, Any]: + async def execute(self, inputs: dict[str, Any]) -> dict[str, Any] | List[dict[str, Any]]: pass def get_unique_name(self) -> str: diff --git a/python-sdk/exospherehost/runtime.py b/python-sdk/exospherehost/runtime.py index 575a7bea..d2465f1c 100644 --- a/python-sdk/exospherehost/runtime.py +++ b/python-sdk/exospherehost/runtime.py @@ -69,7 +69,7 @@ async def _enqueue(self): await sleep(self._poll_interval) - async def _notify_executed(self, state_id: str, outputs: dict[str, Any]): + async def _notify_executed(self, state_id: str, outputs: List[dict[str, Any]]): async with ClientSession() as session: endpoint = self._get_executed_endpoint(state_id) body = {"outputs": outputs} @@ -112,7 +112,12 @@ async def _worker(self): try: node = self._node_mapping[state["node_name"]] outputs = await node.execute(state["inputs"]) # type: ignore + + if isinstance(outputs, dict): + outputs = [outputs] + await self._notify_executed(state["state_id"], outputs) + except Exception as e: await self._notify_errored(state["state_id"], str(e)) diff --git a/state-manager/app/models/executed_models.py b/state-manager/app/models/executed_models.py index 11441a04..dc0935d4 100644 --- a/state-manager/app/models/executed_models.py +++ b/state-manager/app/models/executed_models.py @@ -1,9 +1,9 @@ from pydantic import BaseModel, Field -from typing import Any +from typing import Any, List from .state_status_enum import StateStatusEnum class ExecutedRequestModel(BaseModel): - outputs: dict[str, Any] = Field(..., description="Outputs of the state") + outputs: List[dict[str, Any]] = Field(..., description="Outputs of the state") class ExecutedResponseModel(BaseModel): From 7e6ab240eee661b8c1fcbb23d1812403b728c58a Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Sun, 3 Aug 2025 09:53:02 +0530 Subject: [PATCH 2/3] fixed CI for tests for python api server --- .github/workflows/{ci.yml => test-api-server.yml} | 4 ++++ 1 file changed, 4 insertions(+) rename .github/workflows/{ci.yml => test-api-server.yml} (95%) diff --git a/.github/workflows/ci.yml b/.github/workflows/test-api-server.yml similarity index 95% rename from .github/workflows/ci.yml rename to .github/workflows/test-api-server.yml index c879d0cf..87338a92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/test-api-server.yml @@ -3,8 +3,12 @@ name: Python API Server Tests on: push: branches: [main] + paths: + - 'api-server/**' pull_request: branches: [main] + paths: + - 'api-server/**' jobs: test: From bd0af515c940028e613b919f44ec7e3fc0032de6 Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Sun, 3 Aug 2025 09:55:44 +0530 Subject: [PATCH 3/3] added None check --- python-sdk/exospherehost/runtime.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python-sdk/exospherehost/runtime.py b/python-sdk/exospherehost/runtime.py index d2465f1c..ec014a2a 100644 --- a/python-sdk/exospherehost/runtime.py +++ b/python-sdk/exospherehost/runtime.py @@ -113,6 +113,9 @@ async def _worker(self): node = self._node_mapping[state["node_name"]] outputs = await node.execute(state["inputs"]) # type: ignore + if outputs is None: + outputs = [] + if isinstance(outputs, dict): outputs = [outputs]