bladekit 4.43.2__tar.gz → 4.43.4__tar.gz

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.
Files changed (35) hide show
  1. {bladekit-4.43.2 → bladekit-4.43.4}/.gitignore +2 -0
  2. {bladekit-4.43.2 → bladekit-4.43.4}/PKG-INFO +1 -1
  3. {bladekit-4.43.2 → bladekit-4.43.4}/pyproject.toml +1 -1
  4. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_app.py +8 -2
  5. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_client.py +23 -2
  6. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_cls.py +16 -1
  7. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_map.py +9 -0
  8. {bladekit-4.43.2 → bladekit-4.43.4}/README.md +0 -0
  9. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/__init__.py +0 -0
  10. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_banner.py +0 -0
  11. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_batch.py +0 -0
  12. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_bucket.py +0 -0
  13. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_build.py +0 -0
  14. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_bundle.py +0 -0
  15. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_constants.py +0 -0
  16. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_cron.py +0 -0
  17. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_dict.py +0 -0
  18. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_env.py +0 -0
  19. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_exported_metrics.py +0 -0
  20. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_image.py +0 -0
  21. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_loader.py +0 -0
  22. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_metrics_cli.py +0 -0
  23. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_preempt.py +0 -0
  24. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_queue.py +0 -0
  25. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_render.py +0 -0
  26. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_runner_api.py +0 -0
  27. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_sandbox.py +0 -0
  28. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_secret.py +0 -0
  29. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_serialize.py +0 -0
  30. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_serve.py +0 -0
  31. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_volume.py +0 -0
  32. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/_webhook.py +0 -0
  33. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/cli.py +0 -0
  34. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/config.py +0 -0
  35. {bladekit-4.43.2 → bladekit-4.43.4}/src/bladekit/exceptions.py +0 -0
@@ -30,6 +30,8 @@ node_modules/
30
30
  /e2e/artifacts/
31
31
  /e2e/tutorials/artifacts/
32
32
  /e2e/artifacts-*
33
+ /e2e/metrics/.bin/
34
+ /e2e/metrics/artifacts/
33
35
 
34
36
  # Inference outputs from running the tutorials by hand — the tutorial code
35
37
  # writes these to the working directory, so they land at the repo root. The
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bladekit
3
- Version: 4.43.2
3
+ Version: 4.43.4
4
4
  Summary: Blade AI Fabric SDK + CLI — run Python functions on Blade's GPU fleet.
5
5
  Project-URL: Homepage, https://blade.sh
6
6
  Project-URL: Documentation, https://console.blade.sh
@@ -16,7 +16,7 @@
16
16
  # uninstalled during an upgrade, and `forge` is a different project's name on
17
17
  # public PyPI.
18
18
  name = "bladekit"
19
- version = "4.43.2"
19
+ version = "4.43.4"
20
20
  description = "Blade AI Fabric SDK + CLI — run Python functions on Blade's GPU fleet."
21
21
  readme = "README.md"
22
22
  requires-python = ">=3.10"
@@ -1365,10 +1365,11 @@ class Function:
1365
1365
  gpu_class=self.gpu_class,
1366
1366
  best_effort=self.best_effort,
1367
1367
  max_interruptions=self.max_interruptions,
1368
- # The worker runs carry the function's volumes and secrets, as a
1369
- # single run does.
1368
+ # The worker runs carry the function's volumes, secrets and
1369
+ # @batched config, as a single run does.
1370
1370
  volumes=self._volume_specs(),
1371
1371
  secrets=self._secret_names(),
1372
+ batch_config=self.batch_config,
1372
1373
  )
1373
1374
 
1374
1375
  def _run_map(
@@ -1431,6 +1432,7 @@ class Function:
1431
1432
  max_interruptions=self.max_interruptions,
1432
1433
  volumes=self._volume_specs(),
1433
1434
  secrets=self._secret_names(),
1435
+ batch_config=self.batch_config,
1434
1436
  )
1435
1437
 
1436
1438
  def _refuse_map_bucket_mounts(self) -> None:
@@ -1852,6 +1854,9 @@ class _NamedFunction:
1852
1854
  headers=headers,
1853
1855
  params=params,
1854
1856
  url=_absolute_endpoint_url(endpoint),
1857
+ # Known only for a resolved endpoint; an explicit path= keeps the
1858
+ # token (the endpoint's auth is unknown, and a private one needs it).
1859
+ public=bool((endpoint or {}).get("public")),
1855
1860
  )
1856
1861
  except exc.NotFoundError:
1857
1862
  # The cached endpoint went stale mid-flight (redeploy or rollback
@@ -1881,6 +1886,7 @@ class _NamedFunction:
1881
1886
  headers=headers,
1882
1887
  params=params,
1883
1888
  url=_absolute_endpoint_url(retry_endpoint),
1889
+ public=bool(retry_endpoint.get("public")),
1884
1890
  )
1885
1891
 
1886
1892
  def web(
@@ -229,11 +229,22 @@ class Client:
229
229
 
230
230
  # -- low level ----------------------------------------------------------
231
231
 
232
- def _request(self, method: str, path: str, **kwargs: Any) -> Any:
232
+ def _request(
233
+ self, method: str, path: str, *, send_token: bool = True, **kwargs: Any
234
+ ) -> Any:
233
235
  import httpx
234
236
 
235
237
  try:
236
- resp = self._http.request(method, path, **kwargs)
238
+ if send_token:
239
+ resp = self._http.request(method, path, **kwargs)
240
+ else:
241
+ # Without the client's own Bearer token. A caller-supplied
242
+ # Authorization (the app's own credential) is the caller's to send.
243
+ req = self._http.build_request(method, path, **kwargs)
244
+ caller_headers = kwargs.get("headers") or {}
245
+ if not any(k.lower() == "authorization" for k in caller_headers):
246
+ req.headers.pop("Authorization", None)
247
+ resp = self._http.send(req)
237
248
  except httpx.HTTPError as e: # connect/read/timeout
238
249
  raise exc.ConnectionFailed(
239
250
  f"could not reach control plane at {self.base_url}: {e}"
@@ -900,7 +911,16 @@ class Client:
900
911
  headers: Optional[Mapping[str, str]] = None,
901
912
  params: Optional[Mapping[str, Any]] = None,
902
913
  url: Optional[str] = None,
914
+ public: bool = False,
903
915
  ) -> Any:
916
+ """Invoke a deployed web endpoint through the serving ingress.
917
+
918
+ ``public=True`` (the endpoint's own flag) sends the request WITHOUT this
919
+ client's Blade token: a public endpoint authenticates nobody, and the
920
+ request reaches the app owner's code, so the token would be the caller's
921
+ credential handed to a third party (PAAS-1268). An ``Authorization`` the
922
+ caller passes in ``headers`` is still sent.
923
+ """
904
924
  import httpx
905
925
 
906
926
  if not endpoint_path.startswith("/"):
@@ -940,6 +960,7 @@ class Client:
940
960
  headers=dict(headers or {}),
941
961
  params=dict(params or {}),
942
962
  timeout=_INGRESS_TIMEOUT,
963
+ send_token=not public,
943
964
  )
944
965
  except exc.UnavailableError:
945
966
  if attempt >= _MAX_RETRIES:
@@ -272,7 +272,8 @@ class Method:
272
272
 
273
273
 
274
274
  class _BoundMethod:
275
- """``instance.method`` — exposes ``.remote()`` / ``.spawn()`` / ``.local()``."""
275
+ """``instance.method`` — exposes ``.remote()`` / ``.spawn()`` / ``.local()``
276
+ and the map fan-outs, all carrying the instance's bound parameters."""
276
277
 
277
278
  def __init__(self, method: Method, instance: Any) -> None:
278
279
  self._method = method
@@ -303,6 +304,20 @@ class _BoundMethod:
303
304
  def spawn(self, *args: Any, **kwargs: Any):
304
305
  return self._function().spawn(*args, **kwargs)
305
306
 
307
+ # Map fan-outs: every worker constructs the class with this instance's
308
+ # bound parameters, as .remote() does (they ride in FunctionRef.parameters).
309
+ def map(self, iterable: Any, **kwargs: Any) -> Any:
310
+ return self._function().map(iterable, **kwargs)
311
+
312
+ def starmap(self, iterable: Any, **kwargs: Any) -> Any:
313
+ return self._function().starmap(iterable, **kwargs)
314
+
315
+ def spawn_map(self, iterable: Any, **kwargs: Any) -> Any:
316
+ return self._function().spawn_map(iterable, **kwargs)
317
+
318
+ def spawn_starmap(self, iterable: Any, **kwargs: Any) -> Any:
319
+ return self._function().spawn_starmap(iterable, **kwargs)
320
+
306
321
 
307
322
  class Cls:
308
323
  """An ``@app.cls()``-decorated class: a namespace of remote methods.
@@ -116,6 +116,7 @@ def _create_map_batch(
116
116
  max_interruptions: Optional[int],
117
117
  volumes: Optional[List[dict]],
118
118
  secrets: Optional[List[str]],
119
+ batch_config: Optional[dict],
119
120
  ) -> str:
120
121
  """Create a map invocation, push inputs, finalize; return its ``map_id``.
121
122
 
@@ -162,6 +163,10 @@ def _create_map_batch(
162
163
  body["best_effort"] = True
163
164
  if max_interruptions is not None:
164
165
  body["max_interruptions"] = max_interruptions
166
+ # @batched: each worker fuses up to max_batch_size inputs into one call,
167
+ # as a batched run does (batching.md §4). Omitted when unbatched.
168
+ if batch_config is not None:
169
+ body["batch_config"] = batch_config
165
170
 
166
171
  map_resp = client.create_map(body)
167
172
  map_id = map_resp["map_id"]
@@ -209,6 +214,7 @@ def run_map(
209
214
  max_interruptions: Optional[int] = None,
210
215
  volumes: Optional[List[dict]] = None,
211
216
  secrets: Optional[List[str]] = None,
217
+ batch_config: Optional[dict] = None,
212
218
  ) -> Generator[Any, None, None]:
213
219
  """Create a map batch, push inputs, finalize, stream results.
214
220
 
@@ -238,6 +244,7 @@ def run_map(
238
244
  max_interruptions=max_interruptions,
239
245
  volumes=volumes,
240
246
  secrets=secrets,
247
+ batch_config=batch_config,
241
248
  )
242
249
 
243
250
  # Stream results.
@@ -270,6 +277,7 @@ def spawn_map(
270
277
  max_interruptions: Optional[int] = None,
271
278
  volumes: Optional[List[dict]] = None,
272
279
  secrets: Optional[List[str]] = None,
280
+ batch_config: Optional[dict] = None,
273
281
  ) -> "MapHandle":
274
282
  """Fire an async fan-out and return a :class:`MapHandle` WITHOUT blocking.
275
283
 
@@ -299,6 +307,7 @@ def spawn_map(
299
307
  max_interruptions=max_interruptions,
300
308
  volumes=volumes,
301
309
  secrets=secrets,
310
+ batch_config=batch_config,
302
311
  )
303
312
  return MapHandle(client, map_id)
304
313
 
File without changes
File without changes