spatial-computing 0.24.0__tar.gz → 0.26.0__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 (127) hide show
  1. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/PKG-INFO +1 -1
  2. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/pyproject.toml +1 -1
  3. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/__init__.py +1 -1
  4. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/cli.py +17 -7
  5. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/market/__init__.py +4 -1
  6. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/market/vast.py +51 -7
  7. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial_computing.egg-info/PKG-INFO +1 -1
  8. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_market.py +53 -9
  9. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/LICENSE +0 -0
  10. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/README.md +0 -0
  11. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/setup.cfg +0 -0
  12. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/ai/__init__.py +0 -0
  13. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/ai/kvcache.py +0 -0
  14. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/ai/llm.py +0 -0
  15. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/compute/__init__.py +0 -0
  16. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/compute/cost.py +0 -0
  17. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/compute/detect.py +0 -0
  18. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/compute/monitor.py +0 -0
  19. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/compute/scheduler.py +0 -0
  20. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/compute/taskqueue.py +0 -0
  21. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/compute/worker.py +0 -0
  22. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/compute/workloads.py +0 -0
  23. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/core/__init__.py +0 -0
  24. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/core/auth.py +0 -0
  25. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/core/energy.py +0 -0
  26. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/core/ledger.py +0 -0
  27. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/core/model.py +0 -0
  28. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/core/protocol.py +0 -0
  29. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/core/registry.py +0 -0
  30. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fabric/__init__.py +0 -0
  31. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fabric/cuda.py +0 -0
  32. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fabric/devices.py +0 -0
  33. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fabric/metal.py +0 -0
  34. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fabric/metal_mandel.swift +0 -0
  35. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fabric/metal_run.swift +0 -0
  36. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fleet/__init__.py +0 -0
  37. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fleet/agent.py +0 -0
  38. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fleet/alerts.py +0 -0
  39. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fleet/dashboard.py +0 -0
  40. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fleet/ha.py +0 -0
  41. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/fleet/hub.py +0 -0
  42. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/intelligence/__init__.py +0 -0
  43. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/intelligence/predictor.py +0 -0
  44. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/interconnect/__init__.py +0 -0
  45. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/interconnect/collectives.py +0 -0
  46. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/interconnect/comm.py +0 -0
  47. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/interconnect/model.py +0 -0
  48. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/interconnect/tasks.py +0 -0
  49. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/kernel/__init__.py +0 -0
  50. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/kernel/dsl.py +0 -0
  51. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/kernel/library.py +0 -0
  52. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/memory/__init__.py +0 -0
  53. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/memory/fararray.py +0 -0
  54. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/memory/pageserver.py +0 -0
  55. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/memory/secure.py +0 -0
  56. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/memory/shared.py +0 -0
  57. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/memory/tiered.py +0 -0
  58. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/__init__.py +0 -0
  59. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/billing.py +0 -0
  60. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/db.py +0 -0
  61. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/invoice_rules.py +0 -0
  62. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/mailer.py +0 -0
  63. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/oidc.py +0 -0
  64. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/pdf.py +0 -0
  65. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/qr.py +0 -0
  66. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/security.py +0 -0
  67. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/server.py +0 -0
  68. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/service.py +0 -0
  69. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/app.js +0 -0
  70. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/fonts/DMMono-normal-400.woff2 +0 -0
  71. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/fonts/DMMono-normal-500.woff2 +0 -0
  72. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/fonts/InstrumentSerif-italic-400.woff2 +0 -0
  73. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/fonts/InstrumentSerif-normal-400.woff2 +0 -0
  74. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/fonts/Inter-normal-400.woff2 +0 -0
  75. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/fonts/Inter-normal-500.woff2 +0 -0
  76. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/fonts/Inter-normal-600.woff2 +0 -0
  77. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/fonts.css +0 -0
  78. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/index.html +0 -0
  79. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/logo.svg +0 -0
  80. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/static/style.css +0 -0
  81. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/totp.py +0 -0
  82. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/ubl.py +0 -0
  83. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/platform/vat.py +0 -0
  84. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/__init__.py +0 -0
  85. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/arch.py +0 -0
  86. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/desktop/Dockerfile +0 -0
  87. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/desktop/__init__.py +0 -0
  88. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/desktop/start.sh +0 -0
  89. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/envs.py +0 -0
  90. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/inspect.py +0 -0
  91. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/microvm.py +0 -0
  92. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/planner.py +0 -0
  93. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/runner.py +0 -0
  94. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/runtime/toolchain.py +0 -0
  95. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/unified/__init__.py +0 -0
  96. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/unified/model.py +0 -0
  97. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/unified/planner.py +0 -0
  98. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial/unified/providers.py +0 -0
  99. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial_computing.egg-info/SOURCES.txt +0 -0
  100. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial_computing.egg-info/dependency_links.txt +0 -0
  101. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial_computing.egg-info/entry_points.txt +0 -0
  102. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial_computing.egg-info/requires.txt +0 -0
  103. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/spatial_computing.egg-info/top_level.txt +0 -0
  104. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_auth.py +0 -0
  105. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_compute.py +0 -0
  106. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_core.py +0 -0
  107. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_dashboard.py +0 -0
  108. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_domains.py +0 -0
  109. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_engines.py +0 -0
  110. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_fabric.py +0 -0
  111. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_fleet.py +0 -0
  112. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_ha.py +0 -0
  113. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_hardening.py +0 -0
  114. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_interconnect.py +0 -0
  115. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_kernel.py +0 -0
  116. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_memory.py +0 -0
  117. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_platform.py +0 -0
  118. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_platform2.py +0 -0
  119. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_qr.py +0 -0
  120. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_quorum.py +0 -0
  121. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_real_servers.py +0 -0
  122. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_runtime.py +0 -0
  123. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_sso.py +0 -0
  124. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_unified.py +0 -0
  125. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_v02.py +0 -0
  126. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_v03.py +0 -0
  127. {spatial_computing-0.24.0 → spatial_computing-0.26.0}/tests/test_v05.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatial-computing
3
- Version: 0.24.0
3
+ Version: 0.26.0
4
4
  Summary: Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, fleet)
5
5
  Author: Spatial Computing contributors
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "spatial-computing"
7
- version = "0.24.0"
7
+ version = "0.26.0"
8
8
  description = "Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, fleet)"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -3,4 +3,4 @@
3
3
  Status of every engine is declared in spatial.core.registry and must be backed
4
4
  by a test or benchmark before being set to OPERATIONAL.
5
5
  """
6
- __version__ = "0.24.0"
6
+ __version__ = "0.26.0"
@@ -240,25 +240,34 @@ def cmd_devices(a):
240
240
 
241
241
 
242
242
  def cmd_market(a):
243
- from .market import MarketError, cheapest, fetch_offers, spread_vs
243
+ from .market import MarketError, cheapest, cheapest_for, fetch_offers, spread_for, spread_vs
244
244
  try:
245
245
  offers = fetch_offers()
246
246
  except MarketError as e:
247
247
  print(f"spatial: {e}", file=sys.stderr)
248
248
  return 1
249
+ label = f"vertical {a.vertical!r}" if a.vertical else a.gpu
250
+ try:
251
+ if a.neocloud_usd_per_hour is not None:
252
+ r = spread_for(offers, a.vertical, a.neocloud_usd_per_hour, a.min_reliability) if a.vertical else \
253
+ spread_vs(offers, a.gpu, a.neocloud_usd_per_hour, a.min_reliability)
254
+ else:
255
+ r = None
256
+ c = cheapest_for(offers, a.vertical, a.min_reliability) if a.vertical else cheapest(offers, a.gpu, a.min_reliability)
257
+ except MarketError as e:
258
+ print(f"spatial: {e}", file=sys.stderr)
259
+ return 1
249
260
  if a.neocloud_usd_per_hour is not None:
250
- r = spread_vs(offers, a.gpu, a.neocloud_usd_per_hour, a.min_reliability)
251
261
  if r is None:
252
- print(f"spatial: no Vast.ai offer for {a.gpu!r} at reliability >= {a.min_reliability} right now", file=sys.stderr)
262
+ print(f"spatial: no Vast.ai offer for {label} at reliability >= {a.min_reliability} right now", file=sys.stderr)
253
263
  return 1
254
264
  o = r["offer"]
255
- print(f"cheapest {a.gpu} on Vast.ai right now: {r['market_usd_h']:.3f} $/h (reliability {o.reliability:.3f}, {o.geolocation})")
265
+ print(f"cheapest {label} on Vast.ai right now: {r['market_usd_h']:.3f} $/h ({o.gpu_name}, reliability {o.reliability:.3f}, {o.geolocation})")
256
266
  print(f"your neocloud reference: {r['neocloud_usd_h']:.3f} $/h")
257
267
  print(f"spread: {r['spread_usd_h']:+.3f} $/h ({r['spread_pct']:+.1f} %)")
258
268
  return 0
259
- c = cheapest(offers, a.gpu, a.min_reliability)
260
269
  if c is None:
261
- print(f"spatial: no Vast.ai offer for {a.gpu!r} at reliability >= {a.min_reliability} right now", file=sys.stderr)
270
+ print(f"spatial: no Vast.ai offer for {label} at reliability >= {a.min_reliability} right now", file=sys.stderr)
262
271
  return 1
263
272
  print(f"{c.gpu_name}: {c.usd_per_hour_per_gpu:.3f} $/h per whole GPU (listing {c.usd_per_hour:.3f} $/h at frac {c.gpu_frac:g}), "
264
273
  f"reliability {c.reliability:.3f}, {c.geolocation}")
@@ -341,7 +350,8 @@ def main(argv=None):
341
350
  p.set_defaults(fn=cmd_optimize)
342
351
  sub.add_parser("devices", help="compute devices the planner can use on this machine (CPU, Metal GPU, NVIDIA GPU)").set_defaults(fn=cmd_devices)
343
352
  p = sub.add_parser("market", help="live GPU prices from Vast.ai's public marketplace (read-only, no account, no money spent)")
344
- p.add_argument("--gpu", default="H100", help="substring to match in the GPU name, e.g. H100, RTX 4090, A100")
353
+ p.add_argument("--gpu", default="H100", help="substring to match in the GPU name, e.g. H100, RTX 4090, A100 (ignored if --vertical is given)")
354
+ p.add_argument("--vertical", choices=["render", "cloud_gaming"], help="a preset list of interchangeable GPUs for a market instead of one chip (render = 3D rendering/VFX render-farm cards; cloud_gaming = game-streaming rig cards)")
345
355
  p.add_argument("--min-reliability", type=float, default=0.5, help="Vast.ai's own 0..1 host score; a low-reliability offer is excluded by default")
346
356
  p.add_argument("--neocloud-usd-per-hour", type=float, default=None, help="your reference 'neocloud' price for this GPU: if given, prints the arbitrage spread instead of just the price")
347
357
  p.set_defaults(fn=cmd_market)
@@ -9,4 +9,7 @@ What this module does NOT do: rent a GPU, run a job, or spend any money. Renting
9
9
  running a real job on it is a separate, later step that needs an account on the marketplace and
10
10
  the user's explicit go-ahead each time, since it spends real money.
11
11
  """
12
- from .vast import MarketError, Offer, cheapest, fetch_offers, parse_offers, spread_vs # noqa: F401
12
+ from .vast import ( # noqa: F401
13
+ VERTICALS, MarketError, Offer, cheapest, cheapest_among, cheapest_for, fetch_offers,
14
+ parse_offers, spread_among, spread_for, spread_vs,
15
+ )
@@ -67,19 +67,63 @@ def cheapest(offers: list[Offer], gpu_name_contains: str, min_reliability: float
67
67
  """The lowest per-whole-GPU price among offers whose name contains `gpu_name_contains`
68
68
  (case-insensitive) and whose reliability is at least `min_reliability` (default 0.5: an
69
69
  unreliable host is not a fair price to quote as THE price). None if nothing matches."""
70
- cand = [o for o in offers if gpu_name_contains.lower() in o.gpu_name.lower() and o.reliability >= min_reliability]
70
+ return cheapest_among(offers, (gpu_name_contains,), min_reliability)
71
+
72
+
73
+ def cheapest_among(offers: list[Offer], gpu_names: tuple[str, ...], min_reliability: float = 0.5) -> Offer | None:
74
+ """Like `cheapest()`, but matches ANY of several GPU names (case-insensitive substring): for a
75
+ market made of several interchangeable models — e.g. render/VFX render-farm cards — rather
76
+ than one specific chip. None if nothing matches."""
77
+ cand = [o for o in offers if any(n.lower() in o.gpu_name.lower() for n in gpu_names) and o.reliability >= min_reliability]
71
78
  return min(cand, key=lambda o: o.usd_per_hour_per_gpu) if cand else None
72
79
 
73
80
 
74
- def spread_vs(offers: list[Offer], gpu_name_contains: str, neocloud_usd_per_hour: float,
75
- min_reliability: float = 0.5) -> dict | None:
76
- """The arbitrage spread: the gap between the cheapest sufficiently-reliable marketplace price
77
- for this GPU and a 'neocloud'/list price the CALLER supplies (never invented here). None if no
78
- offer matches. `min_reliability` defaults to 0.5: an unreliable host is not a fair price to quote."""
79
- c = cheapest(offers, gpu_name_contains, min_reliability)
81
+ def _spread(c: Offer | None, neocloud_usd_per_hour: float) -> dict | None:
80
82
  if c is None:
81
83
  return None
82
84
  spread = neocloud_usd_per_hour - c.usd_per_hour_per_gpu
83
85
  return {"market_usd_h": c.usd_per_hour_per_gpu, "neocloud_usd_h": neocloud_usd_per_hour,
84
86
  "spread_usd_h": spread, "spread_pct": (spread / neocloud_usd_per_hour * 100) if neocloud_usd_per_hour else None,
85
87
  "offer": c}
88
+
89
+
90
+ def spread_vs(offers: list[Offer], gpu_name_contains: str, neocloud_usd_per_hour: float,
91
+ min_reliability: float = 0.5) -> dict | None:
92
+ """The arbitrage spread: the gap between the cheapest sufficiently-reliable marketplace price
93
+ for this GPU and a 'neocloud'/list price the CALLER supplies (never invented here). None if no
94
+ offer matches. `min_reliability` defaults to 0.5: an unreliable host is not a fair price to quote."""
95
+ return _spread(cheapest(offers, gpu_name_contains, min_reliability), neocloud_usd_per_hour)
96
+
97
+
98
+ def spread_among(offers: list[Offer], gpu_names: tuple[str, ...], neocloud_usd_per_hour: float,
99
+ min_reliability: float = 0.5) -> dict | None:
100
+ """The arbitrage spread over `cheapest_among()` instead of one specific chip."""
101
+ return _spread(cheapest_among(offers, gpu_names, min_reliability), neocloud_usd_per_hour)
102
+
103
+
104
+ # Presentation presets, same pattern as pk_rtb/pk_credit/... over batch_score (spatial.kernel):
105
+ # a name over the SAME mechanism (cheapest_among/spread_among), not a different one. No code is
106
+ # duplicated per vertical; only the list of GPU names differs.
107
+ VERTICALS: dict[str, tuple[str, ...]] = {
108
+ # 3D rendering / VFX render farms: the cards render engines (Octane, Redshift, V-Ray) are
109
+ # commonly benchmarked and sold against. Not the datacenter chips (H100/A100/B200).
110
+ "render": ("RTX 4090", "RTX 5090", "RTX 4080", "RTX 5080", "RTX PRO 6000", "RTX PRO 5000", "RTX A6000", "RTX 6000 Ada"),
111
+ # Cloud gaming / game streaming (the software side of the "consoles" market, see note in
112
+ # docs/MARKET.md): the gaming-tier cards a streaming rig needs (not the workstation RTX PRO
113
+ # line, not the datacenter chips). This is NOT a console chip and never will be; it is where
114
+ # to place a streamed game session at the lowest measured cost.
115
+ "cloud_gaming": ("RTX 4070", "RTX 4080", "RTX 4090", "RTX 5070", "RTX 5080", "RTX 5090"),
116
+ }
117
+
118
+
119
+ def cheapest_for(offers: list[Offer], vertical: str, min_reliability: float = 0.5) -> Offer | None:
120
+ """`vertical` is a key of VERTICALS (currently: "render", "cloud_gaming")."""
121
+ if vertical not in VERTICALS:
122
+ raise MarketError(f"unknown vertical {vertical!r}; known: {', '.join(VERTICALS)}")
123
+ return cheapest_among(offers, VERTICALS[vertical], min_reliability)
124
+
125
+
126
+ def spread_for(offers: list[Offer], vertical: str, neocloud_usd_per_hour: float, min_reliability: float = 0.5) -> dict | None:
127
+ if vertical not in VERTICALS:
128
+ raise MarketError(f"unknown vertical {vertical!r}; known: {', '.join(VERTICALS)}")
129
+ return spread_among(offers, VERTICALS[vertical], neocloud_usd_per_hour, min_reliability)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spatial-computing
3
- Version: 0.24.0
3
+ Version: 0.26.0
4
4
  Summary: Spatial Computing: open-source infrastructure efficiency toolkit. Measure, decide, prove (compute, tiered memory, runtime routing, fleet)
5
5
  Author: Spatial Computing contributors
6
6
  License-Expression: Apache-2.0
@@ -6,7 +6,7 @@ from pathlib import Path
6
6
 
7
7
  import pytest
8
8
 
9
- from spatial.market import MarketError, cheapest, fetch_offers, parse_offers, spread_vs
9
+ from spatial.market import VERTICALS, MarketError, cheapest, cheapest_among, cheapest_for, fetch_offers, parse_offers, spread_among, spread_for, spread_vs
10
10
 
11
11
  FIXTURE = json.loads((Path(__file__).parent / "data" / "vast_bundles_sample.json").read_text())
12
12
 
@@ -55,18 +55,62 @@ def test_spread_vs_computes_the_arbitrage_gap_against_a_caller_supplied_price():
55
55
  assert spread_vs(offers, "H100", 0.0) is not None and spread_vs(offers, "H100", 0.0)["spread_pct"] is None # no division by zero
56
56
 
57
57
 
58
- def _vast_reachable():
59
- try:
60
- fetch_offers(timeout_s=5.0)
61
- return True
62
- except MarketError:
63
- return False
58
+ def test_cheapest_among_matches_any_of_several_gpu_names():
59
+ offers = parse_offers(FIXTURE)
60
+ c = cheapest_among(offers, ("RTX 4090", "RTX 5090"))
61
+ assert c is not None and c.gpu_name in ("RTX 4090", "RTX 5090", "RTX 4090D") # substring match: "RTX 4090" also matches "RTX 4090D"
62
+ assert cheapest_among(offers, ("no such gpu",)) is None
63
+
64
+
65
+ @pytest.mark.parametrize("vertical", ["render", "cloud_gaming"])
66
+ def test_vertical_is_the_same_mechanism_as_cheapest_among(vertical):
67
+ offers = parse_offers(FIXTURE)
68
+ assert vertical in VERTICALS and len(VERTICALS[vertical]) > 1
69
+ direct = cheapest_among(offers, VERTICALS[vertical])
70
+ via_name = cheapest_for(offers, vertical)
71
+ assert direct == via_name # cheapest_for(vertical) is NOT a different algorithm, just this preset
72
+ with pytest.raises(MarketError, match="unknown vertical"):
73
+ cheapest_for(offers, "no-such-vertical")
74
+
75
+
76
+ def test_cloud_gaming_and_render_verticals_both_target_gaming_tier_cards_not_datacenter_chips():
77
+ for name in VERTICALS["cloud_gaming"] + VERTICALS["render"]:
78
+ assert "RTX" in name and "H100" not in name and "A100" not in name and "B200" not in name
79
+
64
80
 
81
+ @pytest.mark.parametrize("vertical", ["render", "cloud_gaming"])
82
+ def test_spread_for_matches_spread_among_the_same_preset(vertical):
83
+ offers = parse_offers(FIXTURE)
84
+ a = spread_among(offers, VERTICALS[vertical], neocloud_usd_per_hour=1.5)
85
+ b = spread_for(offers, vertical, neocloud_usd_per_hour=1.5)
86
+ assert a == b
87
+ with pytest.raises(MarketError, match="unknown vertical"):
88
+ spread_for(offers, "no-such-vertical", 1.5)
89
+
90
+
91
+ # One real network call for the whole module (not one per test): avoids the flakiness of hitting
92
+ # a live third-party endpoint twice in quick succession, which happened in practice (TLS handshake
93
+ # timeouts under load). Every "live" assertion below reuses this single fetch.
94
+ try:
95
+ _LIVE_OFFERS = fetch_offers(timeout_s=20.0)
96
+ except MarketError:
97
+ _LIVE_OFFERS = None
98
+
99
+ needs_live_market = pytest.mark.skipif(_LIVE_OFFERS is None, reason="Vast.ai's public marketplace is not reachable from here right now")
65
100
 
66
- @pytest.mark.skipif(not _vast_reachable(), reason="Vast.ai's public marketplace is not reachable from here right now")
101
+
102
+ @needs_live_market
67
103
  def test_fetch_offers_is_a_real_live_call_with_plausible_prices():
68
- offers = fetch_offers()
104
+ offers = _LIVE_OFFERS
69
105
  assert len(offers) > 0
70
106
  assert all(o.usd_per_hour >= 0 and 0.0 <= o.reliability <= 1.0 for o in offers)
71
107
  gpu_names = {o.gpu_name for o in offers}
72
108
  assert any("RTX" in n or "A100" in n or "H100" in n or "L4" in n or "4090" in n for n in gpu_names) # a real marketplace, not an empty shell
109
+
110
+
111
+ @needs_live_market
112
+ @pytest.mark.parametrize("vertical", ["render", "cloud_gaming"])
113
+ def test_vertical_finds_a_real_live_offer(vertical):
114
+ c = cheapest_for(_LIVE_OFFERS, vertical)
115
+ if c is not None: # a real marketplace can genuinely have none in stock right now
116
+ assert c.usd_per_hour_per_gpu > 0 and c.reliability >= 0.5