Add package data for GPU rent and update CLI documentation
- Added package data configuration for the 'gpu_rent' package in pyproject.toml. - Updated README.md to include usage instructions for Windows and Unix launchers. - Enhanced CLI documentation in cli.md to reflect new commands and their functionalities. - Revised setup.md to clarify installation steps and environment setup. - Improved error handling and command descriptions in the CLI implementation. - Added new functions for model version handling and flavor resolution in the codebase. - Updated state management to include additional properties for better tracking.
This commit is contained in:
@@ -4,6 +4,7 @@ from gpu_rent.inventory import (
|
||||
match_label,
|
||||
pick_boot_image,
|
||||
rank_flavors,
|
||||
resolve_flavor,
|
||||
)
|
||||
|
||||
|
||||
@@ -41,6 +42,38 @@ def test_gpu_quota_from_compute():
|
||||
assert gpu_quota_from_compute({"GPU_limit": 2}) == 2
|
||||
|
||||
|
||||
def test_resolve_flavor_explicit_and_preference():
|
||||
flavors = [
|
||||
FakeFlavor("d", "RTX 4090 24GB", disabled=True),
|
||||
FakeFlavor("a5", "RTX A5000 24GB"),
|
||||
FakeFlavor("ok", "GPU 1x RTX 4090 24GB"),
|
||||
]
|
||||
picked = resolve_flavor(flavors, ("4090-24", "a5000"))
|
||||
assert picked.id == "ok"
|
||||
explicit = resolve_flavor(flavors, ("a5000",), explicit="a5")
|
||||
assert explicit.id == "a5"
|
||||
|
||||
|
||||
def test_resolve_flavor_prefers_list_over_default_id():
|
||||
flavors = [
|
||||
FakeFlavor("a5", "RTX A5000 24GB"),
|
||||
FakeFlavor("ok", "GPU 1x RTX 4090 24GB"),
|
||||
]
|
||||
picked = resolve_flavor(flavors, ("4090-24", "a5000"), default_id="a5", fallback=True)
|
||||
assert picked.id == "ok"
|
||||
|
||||
|
||||
def test_resolve_flavor_no_fallback_requires_default():
|
||||
flavors = [FakeFlavor("ok", "GPU 1x RTX 4090 24GB")]
|
||||
try:
|
||||
resolve_flavor(flavors, ("4090-24",), fallback=False)
|
||||
raise AssertionError("expected ValueError")
|
||||
except ValueError:
|
||||
pass
|
||||
picked = resolve_flavor(flavors, ("a5000",), default_id="ok", fallback=False)
|
||||
assert picked.id == "ok"
|
||||
|
||||
|
||||
def test_pick_boot_image_prefers_24_580_without_docker():
|
||||
class Img:
|
||||
def __init__(self, name):
|
||||
|
||||
Reference in New Issue
Block a user