render_sdk 0.1.0__py3-none-any.whl → 0.1.1__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/task.py +24 -15
- {render_sdk-0.1.0.dist-info → render_sdk-0.1.1.dist-info}/METADATA +1 -1
- {render_sdk-0.1.0.dist-info → render_sdk-0.1.1.dist-info}/RECORD +7 -7
- {render_sdk-0.1.0.dist-info → render_sdk-0.1.1.dist-info}/WHEEL +1 -1
- {render_sdk-0.1.0.dist-info → render_sdk-0.1.1.dist-info}/LICENSE +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/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=kV9V_Bg9B3ilP_iA9fvDmUhQVUz3uou0oW-W9-8GIyc,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
|
|
@@ -563,12 +563,12 @@ render_sdk/workflows/callback_api/types.py,sha256=AX4orxQZQJat3vZrgjJ-TYb2sNBL8k
|
|
|
563
563
|
render_sdk/workflows/client.py,sha256=P-2RRJydCrQopiVrms1Qoi_mS2z4L1HjDELgjgyZNSI,8448
|
|
564
564
|
render_sdk/workflows/executor.py,sha256=3EevvPeTbYGqmjcJztZUzq85-7EHGErwK91ChnRZj54,3027
|
|
565
565
|
render_sdk/workflows/runner.py,sha256=vJV1vK6sW1zffmCSEBIb1Pg_HwngIZD3TUC1CRoHB6w,4230
|
|
566
|
-
render_sdk/workflows/task.py,sha256=
|
|
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.1.dist-info/LICENSE,sha256=YQ01omJ4YGRAeEslBDXIx9tgO1VbIFYsusdCjQwjwW4,11336
|
|
572
|
+
render_sdk-0.1.1.dist-info/METADATA,sha256=JN8Y8V3d0XeltypRfTlwq4JnAeMbVxB8o7UA9vi1ssM,2707
|
|
573
|
+
render_sdk-0.1.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
574
|
+
render_sdk-0.1.1.dist-info/RECORD,,
|
|
File without changes
|