Skip to content

Commit 84654b9

Browse files
authored
make image_name optional when template_id is provided (#439)
* fix: make image_name optional when template_id is provided * revert: downgrade tqdm
1 parent 6aba7fb commit 84654b9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

runpod/api/ctl_commands.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def get_pod(pod_id: str):
8888

8989
def create_pod(
9090
name: str,
91-
image_name: str,
91+
image_name: Optional[str] = "",
9292
gpu_type_id: Optional[str] = None,
9393
cloud_type: str = "ALL",
9494
support_public_ip: bool = True,
@@ -141,6 +141,10 @@ def create_pod(
141141
>>> pod_id = runpod.create_pod("test", "runpod/stack", instance_id="cpu3c-2-4")
142142
"""
143143
# Input Validation
144+
145+
if not image_name and not template_id:
146+
raise ValueError("Either image_name or template_id must be provided")
147+
144148
if gpu_type_id is not None:
145149
get_gpu(gpu_type_id) # Check if GPU exists, will raise ValueError if not.
146150
if cloud_type not in ["ALL", "COMMUNITY", "SECURE"]:

tests/test_api/test_ctl_commands.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ def test_create_pod(self):
136136
"cloud_type must be one of ALL, COMMUNITY or SECURE",
137137
)
138138

139+
with self.assertRaises(ValueError) as context:
140+
pod = ctl_commands.create_pod(
141+
name="POD_NAME",
142+
gpu_type_id="NVIDIA A100 80GB PCIe",
143+
network_volume_id="NETWORK_VOLUME_ID",
144+
)
145+
146+
self.assertEqual(
147+
str(context.exception),
148+
"Either image_name or template_id must be provided",
149+
)
150+
139151
def test_stop_pod(self):
140152
"""
141153
Test stop_pod

0 commit comments

Comments
 (0)