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 CHANGED
@@ -5,4 +5,4 @@ This package provides:
5
5
  2. REST API Client (render_sdk.client) for interacting with Render's API
6
6
  """
7
7
 
8
- __version__ = "0.1.0"
8
+ __version__ = "0.1.1"
@@ -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
 
@@ -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 TaskCallable:
108
- """A callable that can be awaited to run as a subtask."""
108
+ class TaskInstance:
109
+ """Represents a single task execution that can be awaited."""
109
110
 
110
- def __init__(self, func, name):
111
- self._func = func
111
+ def __init__(self, name: str, future: asyncio.Task):
112
112
  self._name = name
113
- # Copy function attributes for introspection
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
- """Run as a subtask when awaited."""
116
+ """Await the task execution."""
124
117
 
125
118
  async def run_subtask():
126
119
  try:
127
- client = _current_client.get()
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
1
  Metadata-Version: 2.3
2
2
  Name: render_sdk
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Python SDK for Render Workflows
5
5
  Author: Render
6
6
  Author-email: support@render.com
@@ -1,6 +1,6 @@
1
- render_sdk/__init__.py,sha256=Fl_M6R2YTiaSK_ki8zNklB6veGHkwQlXfH-LdCAtj48,215
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=tdSSyxSvUqaOCnm8fdP87xef7soCbQ5aeE-VF6y70Yo,2284
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=iicK96R40cQ7XUiJh7sBVqnyTqBrNQ1SbAfNb5j7CVQ,5047
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.0.dist-info/LICENSE,sha256=YQ01omJ4YGRAeEslBDXIx9tgO1VbIFYsusdCjQwjwW4,11336
572
- render_sdk-0.1.0.dist-info/METADATA,sha256=PRAlkpANkeWdlfxomH1E1q1tlPF9QflG3FbgbGqWGSk,2707
573
- render_sdk-0.1.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
574
- render_sdk-0.1.0.dist-info/RECORD,,
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,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.3
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any