render_sdk 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- render_sdk/__init__.py +1 -1
- render_sdk/client/client.py +5 -0
- render_sdk/workflows/executor.py +1 -1
- render_sdk/workflows/runner.py +8 -17
- render_sdk/workflows/task.py +24 -15
- {render_sdk-0.1.0.dist-info → render_sdk-0.1.2.dist-info}/METADATA +1 -1
- {render_sdk-0.1.0.dist-info → render_sdk-0.1.2.dist-info}/RECORD +9 -9
- {render_sdk-0.1.0.dist-info → render_sdk-0.1.2.dist-info}/LICENSE +0 -0
- {render_sdk-0.1.0.dist-info → render_sdk-0.1.2.dist-info}/WHEEL +0 -0
render_sdk/__init__.py
CHANGED
render_sdk/client/client.py
CHANGED
|
@@ -40,6 +40,11 @@ class Client:
|
|
|
40
40
|
# Set default values
|
|
41
41
|
if token is None:
|
|
42
42
|
self.token = os.getenv("RENDER_API_KEY", "")
|
|
43
|
+
if self.token == "":
|
|
44
|
+
raise ValueError(
|
|
45
|
+
"Either provide a token or set the RENDER_API_KEY "
|
|
46
|
+
+ "environment variable"
|
|
47
|
+
)
|
|
43
48
|
else:
|
|
44
49
|
self.token = token
|
|
45
50
|
|
render_sdk/workflows/executor.py
CHANGED
|
@@ -44,7 +44,7 @@ class TaskExecutor:
|
|
|
44
44
|
|
|
45
45
|
async def execute(self, task_name: str, input_args: list[Any]) -> Any:
|
|
46
46
|
"""Execute a task by name with the given input."""
|
|
47
|
-
logger.
|
|
47
|
+
logger.debug(f"Starting execution of task: {task_name}")
|
|
48
48
|
|
|
49
49
|
sent_error = False
|
|
50
50
|
|
render_sdk/workflows/runner.py
CHANGED
|
@@ -25,18 +25,16 @@ async def run_async(socket_path: str) -> None:
|
|
|
25
25
|
|
|
26
26
|
It gets the input from the server, executes the task, and sends the result back.
|
|
27
27
|
"""
|
|
28
|
-
logger.
|
|
28
|
+
logger.debug("Starting task runner")
|
|
29
29
|
|
|
30
30
|
# Create client
|
|
31
31
|
client = UDSClient(socket_path)
|
|
32
32
|
|
|
33
33
|
try:
|
|
34
34
|
# Get input from server
|
|
35
|
-
logger.
|
|
35
|
+
logger.debug("Getting task input")
|
|
36
36
|
input_response = await client.get_input()
|
|
37
37
|
|
|
38
|
-
logger.info(f"Input response: {input_response}")
|
|
39
|
-
|
|
40
38
|
task_name = input_response.task_name
|
|
41
39
|
raw_input = input_response.input_
|
|
42
40
|
|
|
@@ -50,18 +48,13 @@ async def run_async(socket_path: str) -> None:
|
|
|
50
48
|
else:
|
|
51
49
|
input_data = []
|
|
52
50
|
|
|
53
|
-
logger.info(f"Received input - task: {task_name}, input: {input_data}")
|
|
54
|
-
|
|
55
51
|
# Create executor and execute task
|
|
56
52
|
task_registry = get_task_registry()
|
|
57
53
|
executor = TaskExecutor(task_registry, client)
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
except Exception as e:
|
|
64
|
-
logger.error(f"Task execution failed: {e}")
|
|
55
|
+
logger.debug(f"Executing task: {task_name}")
|
|
56
|
+
await executor.execute(task_name, input_data)
|
|
57
|
+
except Exception:
|
|
65
58
|
raise
|
|
66
59
|
|
|
67
60
|
|
|
@@ -76,7 +69,7 @@ async def register_async(socket_path: str) -> None:
|
|
|
76
69
|
"""
|
|
77
70
|
Register all tasks with the server asynchronously.
|
|
78
71
|
"""
|
|
79
|
-
logger.
|
|
72
|
+
logger.debug("Registering tasks")
|
|
80
73
|
|
|
81
74
|
# Create client
|
|
82
75
|
client = UDSClient(socket_path)
|
|
@@ -105,10 +98,10 @@ async def register_async(socket_path: str) -> None:
|
|
|
105
98
|
tasks.append(task_def)
|
|
106
99
|
|
|
107
100
|
# Register tasks with server
|
|
108
|
-
logger.
|
|
101
|
+
logger.debug(f"Registering {len(tasks)} tasks: {[t.name for t in tasks]}")
|
|
109
102
|
await client.register_tasks(Tasks(tasks=tasks))
|
|
110
103
|
|
|
111
|
-
logger.
|
|
104
|
+
logger.debug("Tasks registered successfully")
|
|
112
105
|
|
|
113
106
|
except Exception as e:
|
|
114
107
|
logger.error(f"Task registration failed: {e}")
|
|
@@ -139,8 +132,6 @@ def start() -> None:
|
|
|
139
132
|
if not socket_path:
|
|
140
133
|
raise ValueError("RENDER_SDK_SOCKET_PATH environment variable is required")
|
|
141
134
|
|
|
142
|
-
logger.info(f"Starting in mode: {mode}")
|
|
143
|
-
|
|
144
135
|
if mode == "run":
|
|
145
136
|
run(socket_path)
|
|
146
137
|
elif mode == "register":
|
render_sdk/workflows/task.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Task decorator and related functionality."""
|
|
2
2
|
|
|
3
|
+
import asyncio
|
|
3
4
|
import contextvars
|
|
4
5
|
import functools
|
|
5
6
|
from abc import ABC, abstractmethod
|
|
@@ -104,28 +105,19 @@ class TaskRegistry:
|
|
|
104
105
|
return task_info.func
|
|
105
106
|
|
|
106
107
|
|
|
107
|
-
class
|
|
108
|
-
"""
|
|
108
|
+
class TaskInstance:
|
|
109
|
+
"""Represents a single task execution that can be awaited."""
|
|
109
110
|
|
|
110
|
-
def __init__(self,
|
|
111
|
-
self._func = func
|
|
111
|
+
def __init__(self, name: str, future: asyncio.Task):
|
|
112
112
|
self._name = name
|
|
113
|
-
|
|
114
|
-
functools.update_wrapper(self, func)
|
|
115
|
-
|
|
116
|
-
def __call__(self, *args, **kwargs):
|
|
117
|
-
# Store args for potential await
|
|
118
|
-
self._args = args
|
|
119
|
-
self._kwargs = kwargs
|
|
120
|
-
return self
|
|
113
|
+
self._future = future
|
|
121
114
|
|
|
122
115
|
def __await__(self):
|
|
123
|
-
"""
|
|
116
|
+
"""Await the task execution."""
|
|
124
117
|
|
|
125
118
|
async def run_subtask():
|
|
126
119
|
try:
|
|
127
|
-
|
|
128
|
-
return await client.run_subtask(self._name, list(self._args))
|
|
120
|
+
return await self._future
|
|
129
121
|
except LookupError as e:
|
|
130
122
|
raise RuntimeError(
|
|
131
123
|
f"Cannot run {self._name} as subtask \
|
|
@@ -135,6 +127,23 @@ class TaskCallable:
|
|
|
135
127
|
return run_subtask().__await__()
|
|
136
128
|
|
|
137
129
|
|
|
130
|
+
class TaskCallable:
|
|
131
|
+
"""A callable that can be awaited to run as a subtask."""
|
|
132
|
+
|
|
133
|
+
def __init__(self, func, name):
|
|
134
|
+
self._func = func
|
|
135
|
+
self._name = name
|
|
136
|
+
# Copy function attributes for introspection
|
|
137
|
+
functools.update_wrapper(self, func)
|
|
138
|
+
|
|
139
|
+
def __call__(self, *args, **kwargs):
|
|
140
|
+
# Create a new TaskInstance for each call
|
|
141
|
+
client = _current_client.get()
|
|
142
|
+
# Start execution immediately
|
|
143
|
+
future = asyncio.create_task(client.run_subtask(self._name, list(args)))
|
|
144
|
+
return TaskInstance(self._name, future)
|
|
145
|
+
|
|
146
|
+
|
|
138
147
|
def create_task_decorator(registry: TaskRegistry) -> Callable:
|
|
139
148
|
"""
|
|
140
149
|
Create a task decorator bound to a specific registry.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
render_sdk/__init__.py,sha256=
|
|
1
|
+
render_sdk/__init__.py,sha256=fXivApwYZa4k0p3j5j4EbyfHIx2wzlWmYfxmrxszeJA,215
|
|
2
2
|
render_sdk/client/__init__.py,sha256=OtkFIaTnPhU6_1yveJwZFRzL3TemdEjZcRvtoYCVhTE,630
|
|
3
|
-
render_sdk/client/client.py,sha256=
|
|
3
|
+
render_sdk/client/client.py,sha256=Relr4rc8qVbEkROBom6VvACKA8AalTZkYby3DPc2-vE,2486
|
|
4
4
|
render_sdk/client/errors.py,sha256=Y1WZV_AOpqvf0_HT5XBQ1JD5jNiEjHrgSiyq8wBfM5U,758
|
|
5
5
|
render_sdk/client/sse.py,sha256=Y-3uWEjfHwfl2g17L6uW2ox5sW1cQKmSojjIVWXuCVA,4419
|
|
6
6
|
render_sdk/client/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -561,14 +561,14 @@ render_sdk/workflows/callback_api/models/tasks.py,sha256=mb3M6wKIb47y3tzl2uompmt
|
|
|
561
561
|
render_sdk/workflows/callback_api/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
|
|
562
562
|
render_sdk/workflows/callback_api/types.py,sha256=AX4orxQZQJat3vZrgjJ-TYb2sNBL8kNo9yqYDT-n8y8,1391
|
|
563
563
|
render_sdk/workflows/client.py,sha256=P-2RRJydCrQopiVrms1Qoi_mS2z4L1HjDELgjgyZNSI,8448
|
|
564
|
-
render_sdk/workflows/executor.py,sha256=
|
|
565
|
-
render_sdk/workflows/runner.py,sha256=
|
|
566
|
-
render_sdk/workflows/task.py,sha256=
|
|
564
|
+
render_sdk/workflows/executor.py,sha256=whdE_q2plZsTt5da-9C5c6Ho7PohVVg2_d7XQy9xQ0c,3028
|
|
565
|
+
render_sdk/workflows/runner.py,sha256=hGeoACuITT96zP8PVfygUdB80T_TtBpUZBbf9yND5r0,3955
|
|
566
|
+
render_sdk/workflows/task.py,sha256=Wh742_vC5JxvY8ifb8cWzefeEioGwgUGjB_bbplUGSA,5315
|
|
567
567
|
render_sdk/workflows/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
568
568
|
render_sdk/workflows/tests/test_end_to_end.py,sha256=eEasR0oCcZWgxZC8H0566I3HP501uK4nzawoEoRVFso,5183
|
|
569
569
|
render_sdk/workflows/tests/test_executor.py,sha256=8l5RtrAJKB3ZiWUr7aE6tVWJgCWWEHfadPvtqc3uvzs,4685
|
|
570
570
|
render_sdk/workflows/tests/test_registration.py,sha256=l0_xUnknCEaE-oO55HYlsbaXQIe9KfUo8DbmJQ7fssw,4004
|
|
571
|
-
render_sdk-0.1.
|
|
572
|
-
render_sdk-0.1.
|
|
573
|
-
render_sdk-0.1.
|
|
574
|
-
render_sdk-0.1.
|
|
571
|
+
render_sdk-0.1.2.dist-info/LICENSE,sha256=YQ01omJ4YGRAeEslBDXIx9tgO1VbIFYsusdCjQwjwW4,11336
|
|
572
|
+
render_sdk-0.1.2.dist-info/METADATA,sha256=F1SxdFvdcP1LZ-3oe-Nnr51NZca0muPM9LiyVyEKkKM,2707
|
|
573
|
+
render_sdk-0.1.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
574
|
+
render_sdk-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|