bladekit 4.43.1__tar.gz → 4.43.3__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.1 → bladekit-4.43.3}/.gitignore +2 -0
  2. {bladekit-4.43.1 → bladekit-4.43.3}/PKG-INFO +1 -1
  3. {bladekit-4.43.1 → bladekit-4.43.3}/pyproject.toml +1 -1
  4. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_app.py +32 -4
  5. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_cls.py +16 -1
  6. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_map.py +25 -0
  7. {bladekit-4.43.1 → bladekit-4.43.3}/README.md +0 -0
  8. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/__init__.py +0 -0
  9. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_banner.py +0 -0
  10. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_batch.py +0 -0
  11. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_bucket.py +0 -0
  12. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_build.py +0 -0
  13. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_bundle.py +0 -0
  14. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_client.py +0 -0
  15. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_constants.py +0 -0
  16. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_cron.py +0 -0
  17. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_dict.py +0 -0
  18. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_env.py +0 -0
  19. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_exported_metrics.py +0 -0
  20. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_image.py +0 -0
  21. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_loader.py +0 -0
  22. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_metrics_cli.py +0 -0
  23. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_preempt.py +0 -0
  24. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_queue.py +0 -0
  25. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_render.py +0 -0
  26. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_runner_api.py +0 -0
  27. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_sandbox.py +0 -0
  28. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_secret.py +0 -0
  29. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_serialize.py +0 -0
  30. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_serve.py +0 -0
  31. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_volume.py +0 -0
  32. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/_webhook.py +0 -0
  33. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/cli.py +0 -0
  34. {bladekit-4.43.1 → bladekit-4.43.3}/src/bladekit/config.py +0 -0
  35. {bladekit-4.43.1 → bladekit-4.43.3}/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.1
3
+ Version: 4.43.3
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.1"
19
+ version = "4.43.3"
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"
@@ -1173,8 +1173,9 @@ class Function:
1173
1173
  retries: override the retry policy for this batch, e.g.
1174
1174
  ``{"max_retries": 3, "backoff": {"initial_seconds": 1,
1175
1175
  "max_seconds": 60, "factor": 2.0}}``.
1176
- input_timeout_seconds: per-input timeout (distinct from the run
1177
- global ``timeout=``).
1176
+ input_timeout_seconds: per-input timeout. Defaults to the
1177
+ function's ``timeout=`` (max seconds for ONE execution); an
1178
+ input that exceeds it fails with INPUT_TIMEOUT (retries apply).
1178
1179
  priority: scheduling priority 0–9 (9=urgent, 0=best-effort batch).
1179
1180
  Defaults to the function's priority or 5 (FIFO).
1180
1181
  namespace: override the namespace for quota accounting.
@@ -1330,6 +1331,7 @@ class Function:
1330
1331
  from ._map import spawn_map as _spawn_map_impl
1331
1332
  from ._serialize import cloudpickle_version
1332
1333
 
1334
+ self._refuse_map_bucket_mounts()
1333
1335
  client = self._app._require_client()
1334
1336
  bundle_id = self._app._ensure_bundle()
1335
1337
  image_str, image_build_id = self._resolve_image()
@@ -1356,13 +1358,18 @@ class Function:
1356
1358
  app_name=self._app.name if self._app.name else None,
1357
1359
  inputs=inputs,
1358
1360
  retries=eff_retries,
1359
- input_timeout_seconds=input_timeout_seconds,
1361
+ input_timeout_seconds=self._map_input_timeout(input_timeout_seconds),
1360
1362
  priority=eff_priority,
1361
1363
  namespace=eff_namespace,
1362
1364
  max_concurrency=max_concurrency,
1363
1365
  gpu_class=self.gpu_class,
1364
1366
  best_effort=self.best_effort,
1365
1367
  max_interruptions=self.max_interruptions,
1368
+ # The worker runs carry the function's volumes, secrets and
1369
+ # @batched config, as a single run does.
1370
+ volumes=self._volume_specs(),
1371
+ secrets=self._secret_names(),
1372
+ batch_config=self.batch_config,
1366
1373
  )
1367
1374
 
1368
1375
  def _run_map(
@@ -1381,6 +1388,7 @@ class Function:
1381
1388
  from ._map import run_map
1382
1389
  from ._serialize import cloudpickle_version
1383
1390
 
1391
+ self._refuse_map_bucket_mounts()
1384
1392
  client = self._app._require_client()
1385
1393
  bundle_id = self._app._ensure_bundle()
1386
1394
  image_str, image_build_id = self._resolve_image()
@@ -1413,7 +1421,7 @@ class Function:
1413
1421
  order=order,
1414
1422
  return_exceptions=return_exceptions,
1415
1423
  retries=eff_retries,
1416
- input_timeout_seconds=input_timeout_seconds,
1424
+ input_timeout_seconds=self._map_input_timeout(input_timeout_seconds),
1417
1425
  priority=eff_priority,
1418
1426
  namespace=eff_namespace,
1419
1427
  max_concurrency=max_concurrency,
@@ -1422,8 +1430,28 @@ class Function:
1422
1430
  gpu_class=self.gpu_class,
1423
1431
  best_effort=self.best_effort,
1424
1432
  max_interruptions=self.max_interruptions,
1433
+ volumes=self._volume_specs(),
1434
+ secrets=self._secret_names(),
1435
+ batch_config=self.batch_config,
1425
1436
  )
1426
1437
 
1438
+ def _refuse_map_bucket_mounts(self) -> None:
1439
+ """Map workers cannot mount a CloudBucketMount yet (the control plane
1440
+ has no bucket mounts on POST /v1/maps): refuse before any request
1441
+ rather than start workers whose mount path is silently empty."""
1442
+ if self._bucket_mount_specs():
1443
+ raise exc.InvalidArgumentError(
1444
+ "INVALID_ARGUMENT",
1445
+ "bucket mounts are not supported on map yet; use .remote()/.spawn()",
1446
+ )
1447
+
1448
+ def _map_input_timeout(self, explicit: Optional[int]) -> Optional[int]:
1449
+ """Per-input timeout of a map: explicit argument > the function's
1450
+ ``timeout=``. ``timeout=`` is the max seconds for ONE execution, and a
1451
+ map execution is one input — never the lifetime of a worker run, which
1452
+ serves many inputs. None ⇒ no per-input limit (the server default)."""
1453
+ return explicit if explicit is not None else self.timeout
1454
+
1427
1455
  # -- result resolution --------------------------------------------------
1428
1456
 
1429
1457
  def _await_call(
@@ -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.
@@ -114,6 +114,9 @@ def _create_map_batch(
114
114
  gpu_class: str,
115
115
  best_effort: bool,
116
116
  max_interruptions: Optional[int],
117
+ volumes: Optional[List[dict]],
118
+ secrets: Optional[List[str]],
119
+ batch_config: Optional[dict],
117
120
  ) -> str:
118
121
  """Create a map invocation, push inputs, finalize; return its ``map_id``.
119
122
 
@@ -134,6 +137,12 @@ def _create_map_batch(
134
137
  body["image"] = image
135
138
  if image_build_id is not None:
136
139
  body["image_build_id"] = image_build_id
140
+ # The worker runs' volumes and secrets, in the run-create shape (resources
141
+ # already carries timeout_seconds). Omitted when empty, like the run body.
142
+ if volumes:
143
+ body["volumes"] = volumes
144
+ if secrets:
145
+ body["secrets"] = secrets
137
146
  if app_name:
138
147
  body["app_name"] = app_name
139
148
  if retries is not None:
@@ -154,6 +163,10 @@ def _create_map_batch(
154
163
  body["best_effort"] = True
155
164
  if max_interruptions is not None:
156
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
157
170
 
158
171
  map_resp = client.create_map(body)
159
172
  map_id = map_resp["map_id"]
@@ -199,6 +212,9 @@ def run_map(
199
212
  gpu_class: str = "spot",
200
213
  best_effort: bool = False,
201
214
  max_interruptions: Optional[int] = None,
215
+ volumes: Optional[List[dict]] = None,
216
+ secrets: Optional[List[str]] = None,
217
+ batch_config: Optional[dict] = None,
202
218
  ) -> Generator[Any, None, None]:
203
219
  """Create a map batch, push inputs, finalize, stream results.
204
220
 
@@ -226,6 +242,9 @@ def run_map(
226
242
  gpu_class=gpu_class,
227
243
  best_effort=best_effort,
228
244
  max_interruptions=max_interruptions,
245
+ volumes=volumes,
246
+ secrets=secrets,
247
+ batch_config=batch_config,
229
248
  )
230
249
 
231
250
  # Stream results.
@@ -256,6 +275,9 @@ def spawn_map(
256
275
  gpu_class: str = "spot",
257
276
  best_effort: bool = False,
258
277
  max_interruptions: Optional[int] = None,
278
+ volumes: Optional[List[dict]] = None,
279
+ secrets: Optional[List[str]] = None,
280
+ batch_config: Optional[dict] = None,
259
281
  ) -> "MapHandle":
260
282
  """Fire an async fan-out and return a :class:`MapHandle` WITHOUT blocking.
261
283
 
@@ -283,6 +305,9 @@ def spawn_map(
283
305
  gpu_class=gpu_class,
284
306
  best_effort=best_effort,
285
307
  max_interruptions=max_interruptions,
308
+ volumes=volumes,
309
+ secrets=secrets,
310
+ batch_config=batch_config,
286
311
  )
287
312
  return MapHandle(client, map_id)
288
313
 
File without changes
File without changes