Skip to content

Commit ede00d9

Browse files
committed
Refactor Runtime class to rename 'workers' to 'thread_count' for clarity and update related documentation and tests accordingly.
1 parent 27ae0c9 commit ede00d9

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

python-sdk/exospherehost/runtime.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Runtime:
3636
key (str | None, optional): API key for authentication.
3737
If not provided, will use the EXOSPHERE_API_KEY environment variable.
3838
batch_size (int, optional): Number of states to fetch per poll. Defaults to 16.
39-
workers (int, optional): Number of concurrent worker tasks. Defaults to 4.
39+
thread_count (int, optional): Number of concurrent worker threads. Defaults to 4.
4040
state_manage_version (str, optional): State manager API version. Defaults to "v0".
4141
poll_interval (int, optional): Seconds between polling for new states. Defaults to 1.
4242
@@ -83,7 +83,7 @@ def _validate_runtime(self):
8383
Validate runtime configuration.
8484
8585
Raises:
86-
ValueError: If batch_size or workers is less than 1, or if required
86+
ValueError: If batch_size or thread_count is less than 1, or if required
8787
configuration (state_manager_uri, key) is not provided.
8888
"""
8989
if self._batch_size < 1:
@@ -310,7 +310,7 @@ def _validate_nodes(self):
310310

311311
async def _worker_thread(self):
312312
"""
313-
Worker task that processes states from the queue.
313+
Worker thread that processes states from the queue.
314314
315315
Continuously fetches states from the queue, executes the corresponding node,
316316
and notifies the state manager of the result.
@@ -340,17 +340,17 @@ async def _start(self):
340340
"""
341341
Start the runtime event loop.
342342
343-
Registers nodes, starts the polling and worker tasks, and runs until stopped.
343+
Registers nodes, starts the polling and worker threads, and runs until stopped.
344344
345345
Raises:
346346
RuntimeError: If the runtime is not connected (no nodes registered).
347347
"""
348348
await self._register()
349349

350350
poller = asyncio.create_task(self._enqueue())
351-
worker_tasks = [asyncio.create_task(self._worker_thread()) for _ in range(self._thread_count)]
351+
worker_threads = [asyncio.create_task(self._worker_thread()) for _ in range(self._thread_count)]
352352

353-
await asyncio.gather(poller, *worker_tasks)
353+
await asyncio.gather(poller, *worker_threads)
354354

355355
def start(self):
356356
"""

python-sdk/tests/test_runtime_validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class Secrets(BaseModel):
1515
api_key: str
1616

1717
async def execute(self):
18-
return self.Outputs(message=f"hi {self.inputs.name}")
18+
return self.Outputs(message=f"hi {self.inputs.name}") # type: ignore
1919

2020

2121
class BadNodeWrongInputsBase(BaseNode):
22-
Inputs = object # not a pydantic BaseModel
22+
Inputs = object # not a pydantic BaseModel # type: ignore
2323
class Outputs(BaseModel):
2424
message: str
2525
class Secrets(BaseModel):
@@ -62,7 +62,7 @@ def test_runtime_invalid_params_raises(monkeypatch):
6262
with pytest.raises(ValueError):
6363
Runtime(namespace="ns", name="rt", nodes=[GoodNode], batch_size=0)
6464
with pytest.raises(ValueError):
65-
Runtime(namespace="ns", name="rt", nodes=[GoodNode], workers=0)
65+
Runtime(namespace="ns", name="rt", nodes=[GoodNode], thread_count=0)
6666

6767

6868
def test_node_validation_errors(monkeypatch):

0 commit comments

Comments
 (0)