Skip to content

Commit

Permalink
restore deprecated gpu attribute (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
zubenkoivan authored Dec 20, 2024
1 parent 0a6eed2 commit e2693f6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 16 deletions.
8 changes: 6 additions & 2 deletions neuro_config_client/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class NodePool:

disk_type: str | None = None

gpu: int | None = None # Deprecated. Use nvidia_gpu instead
gpu_model: str | None = None # Deprecated. Use nvidia_gpu_model instead
nvidia_gpu: int | None = None
nvidia_gpu_model: str | None = None
amd_gpu: int | None = None
Expand Down Expand Up @@ -535,11 +537,13 @@ class ResourcePoolType:
disk_size: int = 150 * 2**30 # 150gb
available_disk_size: int = 150 * 2**30 # 150gb

gpu: int | None = None # Deprecated. Use nvidia_gpu instead
gpu_model: str | None = None # Deprecated. Use nvidia_gpu_model instead
nvidia_gpu: int | None = None
amd_gpu: int | None = None
intel_gpu: int | None = None
nvidia_gpu_model: str | None = None
amd_gpu: int | None = None
amd_gpu_model: str | None = None
intel_gpu: int | None = None
intel_gpu_model: str | None = None
tpu: TPUResource | None = None

Expand Down
32 changes: 21 additions & 11 deletions neuro_config_client/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def create_resource_pool_type(self, payload: dict[str, Any]) -> ResourcePoolType
tpu = self.create_tpu_resource(payload["tpu"])
cpu = payload.get("cpu", ResourcePoolType.cpu)
memory = payload.get("memory", ResourcePoolType.memory)
nvidia_gpu = payload.get("nvidia_gpu") or payload.get("gpu")
nvidia_gpu_model = payload.get("nvidia_gpu_model") or payload.get("gpu_model")
return ResourcePoolType(
name=payload["name"],
min_size=payload.get("min_size", ResourcePoolType.min_size),
Expand All @@ -213,11 +215,13 @@ def create_resource_pool_type(self, payload: dict[str, Any]) -> ResourcePoolType
available_cpu=payload.get("available_cpu") or cpu,
memory=memory,
available_memory=payload.get("available_memory") or memory,
nvidia_gpu=payload.get("nvidia_gpu"),
gpu=nvidia_gpu,
gpu_model=nvidia_gpu_model,
nvidia_gpu=nvidia_gpu,
nvidia_gpu_model=nvidia_gpu_model,
amd_gpu=payload.get("amd_gpu"),
intel_gpu=payload.get("intel_gpu"),
nvidia_gpu_model=payload.get("nvidia_gpu_model"),
amd_gpu_model=payload.get("amd_gpu_model"),
intel_gpu=payload.get("intel_gpu"),
intel_gpu_model=payload.get("intel_gpu_model"),
price=Decimal(payload.get("price", ResourcePoolType.price)),
currency=payload.get("currency"),
Expand Down Expand Up @@ -385,6 +389,8 @@ def create_node_pool(self, payload: dict[str, Any]) -> NodePool:
price_value = payload.get("price")
price = Decimal(price_value) if price_value is not None else NodePool.price
disk_size = payload.get("disk_size", 0)
nvidia_gpu = payload.get("nvidia_gpu") or payload.get("gpu")
nvidia_gpu_model = payload.get("nvidia_gpu_model") or payload.get("gpu_model")
return NodePool(
name=payload["name"],
role=NodeRole(payload["role"]),
Expand All @@ -397,10 +403,10 @@ def create_node_pool(self, payload: dict[str, Any]) -> NodePool:
disk_size=disk_size,
available_disk_size=payload.get("available_disk_size", disk_size),
disk_type=payload.get("disk_type", NodePool.disk_type),
nvidia_gpu=payload.get("nvidia_gpu") or payload.get("gpu"),
nvidia_gpu_model=(
payload.get("nvidia_gpu_model") or payload.get("gpu_model")
),
gpu=nvidia_gpu,
gpu_model=nvidia_gpu_model,
nvidia_gpu=nvidia_gpu,
nvidia_gpu_model=nvidia_gpu_model,
amd_gpu=payload.get("amd_gpu"),
amd_gpu_model=payload.get("amd_gpu_model"),
intel_gpu=payload.get("intel_gpu"),
Expand Down Expand Up @@ -922,16 +928,20 @@ def create_resource_pool_type(
"disk_size": resource_pool_type.disk_size,
"available_disk_size": resource_pool_type.available_disk_size,
}
if resource_pool_type.gpu:
result["nvidia_gpu"] = resource_pool_type.gpu
if resource_pool_type.gpu_model:
result["nvidia_gpu_model"] = resource_pool_type.gpu_model
if resource_pool_type.nvidia_gpu:
result["nvidia_gpu"] = resource_pool_type.nvidia_gpu
if resource_pool_type.amd_gpu:
result["amd_gpu"] = resource_pool_type.amd_gpu
if resource_pool_type.intel_gpu:
result["intel_gpu"] = resource_pool_type.intel_gpu
if resource_pool_type.nvidia_gpu_model:
result["nvidia_gpu_model"] = resource_pool_type.nvidia_gpu_model
if resource_pool_type.amd_gpu:
result["amd_gpu"] = resource_pool_type.amd_gpu
if resource_pool_type.amd_gpu_model:
result["amd_gpu_model"] = resource_pool_type.amd_gpu_model
if resource_pool_type.intel_gpu:
result["intel_gpu"] = resource_pool_type.intel_gpu
if resource_pool_type.intel_gpu_model:
result["intel_gpu_model"] = resource_pool_type.intel_gpu_model
if resource_pool_type.currency:
Expand Down
18 changes: 15 additions & 3 deletions tests/test_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,13 @@ def test_create_resource_pool_type(
available_cpu=3.0,
memory=12 * 1024,
available_memory=10 * 1024,
gpu=1,
gpu_model=nvidia_small_gpu,
nvidia_gpu=1,
amd_gpu=2,
intel_gpu=3,
nvidia_gpu_model=nvidia_small_gpu,
amd_gpu=2,
amd_gpu_model=amd_small_gpu,
intel_gpu=3,
intel_gpu_model=intel_small_gpu,
tpu=mock.ANY,
is_preemptible=True,
Expand Down Expand Up @@ -421,9 +423,9 @@ def test_create_resource_preset_custom(
cpu=4.0,
memory=12288,
nvidia_gpu=1,
nvidia_gpu_model=nvidia_small_gpu,
amd_gpu=2,
intel_gpu=3,
nvidia_gpu_model=nvidia_small_gpu,
amd_gpu_model=amd_small_gpu,
intel_gpu_model=intel_small_gpu,
tpu=TPUPreset(type="tpu", software_version="v1"),
Expand Down Expand Up @@ -664,6 +666,8 @@ def google_cloud_provider(self) -> GoogleCloudProvider:
available_memory=201 * 1024,
disk_size=700,
available_disk_size=670,
gpu=1,
gpu_model="nvidia-tesla-k80",
nvidia_gpu=1,
nvidia_gpu_model="nvidia-tesla-k80",
is_preemptible=True,
Expand Down Expand Up @@ -776,6 +780,8 @@ def aws_cloud_provider(self) -> AWSCloudProvider:
available_memory=57 * 1024,
disk_size=700,
available_disk_size=670,
gpu=1,
gpu_model="nvidia-tesla-k80",
nvidia_gpu=1,
nvidia_gpu_model="nvidia-tesla-k80",
is_preemptible=True,
Expand Down Expand Up @@ -892,6 +898,8 @@ def azure_cloud_provider(self) -> AzureCloudProvider:
available_memory=50 * 1024,
disk_size=700,
available_disk_size=670,
gpu=1,
gpu_model="nvidia-tesla-k80",
nvidia_gpu=1,
nvidia_gpu_model="nvidia-tesla-k80",
is_preemptible=True,
Expand Down Expand Up @@ -990,6 +998,8 @@ def on_prem_cloud_provider(self) -> OnPremCloudProvider:
available_memory=1024,
disk_size=700,
available_disk_size=700,
gpu=1,
gpu_model="nvidia-tesla-k80",
nvidia_gpu=1,
nvidia_gpu_model="nvidia-tesla-k80",
price=Decimal("0.9"),
Expand Down Expand Up @@ -1110,6 +1120,8 @@ def vcd_cloud_provider(self) -> VCDCloudProvider:
available_memory=37 * 1024,
disk_size=700,
available_disk_size=670,
gpu=1,
gpu_model="nvidia-tesla-k80",
nvidia_gpu=1,
nvidia_gpu_model="nvidia-tesla-k80",
price=Decimal("0.9"),
Expand Down

0 comments on commit e2693f6

Please sign in to comment.