Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion runpod/api/ctl_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_pod(pod_id: str):

def create_pod(
name: str,
image_name: str,
image_name: Optional[str] = "",
gpu_type_id: Optional[str] = None,
cloud_type: str = "ALL",
support_public_ip: bool = True,
Expand Down Expand Up @@ -141,6 +141,10 @@ def create_pod(
>>> pod_id = runpod.create_pod("test", "runpod/stack", instance_id="cpu3c-2-4")
"""
# Input Validation

if not image_name and not template_id:
raise ValueError("Either image_name or template_id must be provided")

if gpu_type_id is not None:
get_gpu(gpu_type_id) # Check if GPU exists, will raise ValueError if not.
if cloud_type not in ["ALL", "COMMUNITY", "SECURE"]:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_api/test_ctl_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ def test_create_pod(self):
"cloud_type must be one of ALL, COMMUNITY or SECURE",
)

with self.assertRaises(ValueError) as context:
pod = ctl_commands.create_pod(
name="POD_NAME",
gpu_type_id="NVIDIA A100 80GB PCIe",
network_volume_id="NETWORK_VOLUME_ID",
)

self.assertEqual(
str(context.exception),
"Either image_name or template_id must be provided",
)

def test_stop_pod(self):
"""
Test stop_pod
Expand Down
Loading