Pick cheapest GPU SKU and pin the VM to an existing disk AZ.

Scan ru-6 by Nova availability zones (a/b/c). First boot uses FLAVOR_SIZE_PRESET=cheap; reruns stay on the disk segment.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-22 00:06:44 +03:00
co-authored by Cursor
parent 5d0c30f66b
commit 789fa26918
19 changed files with 666 additions and 71 deletions
+33 -1
View File
@@ -1,4 +1,4 @@
from gpu_rent.pools import PoolGpuOffer, format_pool_scan
from gpu_rent.pools import AzGpuOffer, PoolGpuOffer, format_pool_scan
def test_format_pool_scan_recommends_first_hit():
@@ -14,9 +14,41 @@ def test_format_pool_scan_recommends_first_hit():
matched=[
FlavorInfo("1", "GL-4090", 4, 16384, False, {}, "4090-24"),
],
recommended_az="ru-6a",
segments=[
AzGpuOffer(
az="ru-6a",
gpu_labels_found=["4090-24"],
gpu_types=["RTX4090"],
matched=[FlavorInfo("1", "GL-4090", 4, 16384, False, {}, "4090-24")],
),
AzGpuOffer(az="ru-6b", gpu_labels_found=[], gpu_types=["H200"], matched=[]),
AzGpuOffer(az="ru-6c", gpu_labels_found=[], gpu_types=["H200"], matched=[]),
],
),
]
text = "\n".join(format_pool_scan(offers, ("4090-24", "4090-48")))
assert "ru-6" in text and "multizone" in text
assert "типы:" in text
assert "ru-6a" in text and "ru-6b" in text and "ru-6c" in text
assert "рекомендация:" in text and "OS_REGION_NAME=ru-6" in text
assert "GPU_RENT_AZ=ru-6a" in text
def test_format_pool_scan_pins_disk_az():
from gpu_rent.inventory import FlavorInfo
offers = [
PoolGpuOffer(
region="ru-6",
multizone=True,
gpu_labels_found=["4090-24"],
gpu_types=["RTX4090"],
matched=[FlavorInfo("1", "GL-4090", 4, 16384, False, {}, "4090-24")],
recommended_az="ru-6a",
)
]
text = "\n".join(
format_pool_scan(offers, ("4090-24",), pin_az="ru-6a", size_preset="cheap")
)
assert "диск уже в ru-6a" in text