Skip to content

Commit 11849cc

Browse files
authored
add better default value selection when creating pods (#25)
* add better default value selection when creating pods * simplify connecting to machine and show private key path * improve display of secure cloud
1 parent 7a4c41b commit 11849cc

File tree

3 files changed

+53
-23
lines changed

3 files changed

+53
-23
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "prime-cli"
3-
version = "0.2.5"
3+
version = "0.2.6"
44
description = "Prime Intellect CLI"
55
readme = "README.md"
66
requires-python = ">=3.8"

src/prime_cli/commands/availability.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ def list(
9292
table.add_column("Location", style="green")
9393
table.add_column("Stock", style="yellow")
9494
table.add_column("Price/Hr", style="magenta")
95-
table.add_column("Memory (GB)", style="blue")
9695
table.add_column("Security", style="white")
9796
table.add_column("vCPUs", style="blue")
9897
table.add_column("RAM (GB)", style="blue")
98+
table.add_column("Disk (GB)", style="blue")
9999

100100
all_gpus: List[Dict[str, Any]] = []
101101
for gpu_type, gpus in availability_data.items():
@@ -113,6 +113,14 @@ def list(
113113
location = f"{gpu.country or 'N/A'}"
114114

115115
short_id = generate_short_id(gpu)
116+
117+
disk_info: str = str(gpu.disk.default_count)
118+
if (
119+
gpu.disk.max_count is not None
120+
and gpu.disk.max_count != gpu.disk.default_count
121+
):
122+
disk_info = f"{gpu.disk.default_count}+"
123+
116124
gpu_data = {
117125
"short_id": short_id,
118126
"cloud_id": gpu.cloud_id,
@@ -129,6 +137,7 @@ def list(
129137
"vcpu": gpu.vcpu.default_count,
130138
"memory": gpu.memory.default_count,
131139
"is_spot": gpu.is_spot,
140+
"disk": disk_info,
132141
}
133142
all_gpus.append(gpu_data)
134143

@@ -158,8 +167,14 @@ def list(
158167
max_vcpu = max(g["vcpu"] for g in group)
159168
min_mem = min(g["memory"] for g in group)
160169
max_mem = max(g["memory"] for g in group)
161-
vcpu_range = f"{min_vcpu}-{max_vcpu}"
162-
memory_range = f"{min_mem}-{max_mem}"
170+
vcpu_range = (
171+
f"{min_vcpu}-{max_vcpu}"
172+
if min_vcpu != max_vcpu
173+
else str(min_vcpu)
174+
)
175+
memory_range = (
176+
f"{min_mem}-{max_mem}" if min_mem != max_mem else str(min_mem)
177+
)
163178
base["vcpu"] = vcpu_range
164179
base["memory"] = memory_range
165180
filtered_gpus.append(base)
@@ -178,7 +193,7 @@ def list(
178193
f"{gpu_entry['gpu_type']} (Spot)"
179194
if gpu_entry["is_spot"]
180195
else gpu_entry["gpu_type"]
181-
)
196+
).replace("_", " ")
182197
table.add_row(
183198
gpu_entry["short_id"],
184199
gpu_type_display,
@@ -188,10 +203,12 @@ def list(
188203
gpu_entry["location"],
189204
gpu_entry["stock_status"],
190205
gpu_entry["price"],
191-
str(gpu_entry["gpu_memory"]),
192-
gpu_entry["security"],
206+
"community"
207+
if gpu_entry["security"] == "community_cloud"
208+
else "datacenter",
193209
str(gpu_entry["vcpu"]),
194210
str(gpu_entry["memory"]),
211+
str(gpu_entry["disk"]),
195212
)
196213

197214
console.print(table)

src/prime_cli/commands/pods.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,12 @@ def create(
383383

384384
if not name:
385385
while True:
386+
gpu_name = selected_gpu.gpu_type.lower().split("_")[0]
387+
default_name = f"{gpu_name}-{selected_gpu.gpu_count}"
386388
name = typer.prompt(
387389
"Pod name (alphanumeric and dashes only, must contain at least "
388390
"1 letter)",
391+
default=default_name,
389392
)
390393
if (
391394
name
@@ -468,21 +471,25 @@ def create(
468471
raise typer.Exit(1)
469472

470473
if not image and selected_gpu.images:
471-
# Show available images
472-
console.print("\n[bold]Available Images:[/bold]")
473-
for idx, img in enumerate(selected_gpu.images):
474-
console.print(f"{idx + 1}. {img}")
475-
476-
# Prompt for image selection
477-
image_idx = typer.prompt(
478-
"Select image number", type=int, default=1, show_default=False
479-
)
474+
if len(selected_gpu.images) == 1:
475+
# If only one image available, use it directly
476+
image = selected_gpu.images[0]
477+
else:
478+
# Show available images
479+
console.print("\n[bold]Available Images:[/bold]")
480+
for idx, img in enumerate(selected_gpu.images):
481+
console.print(f"{idx + 1}. {img}")
482+
483+
# Prompt for image selection
484+
image_idx = typer.prompt(
485+
"Select image number", type=int, default=1, show_default=False
486+
)
480487

481-
if image_idx < 1 or image_idx > len(selected_gpu.images):
482-
console.print("[red]Invalid image selection[/red]")
483-
raise typer.Exit(1)
488+
if image_idx < 1 or image_idx > len(selected_gpu.images):
489+
console.print("[red]Invalid image selection[/red]")
490+
raise typer.Exit(1)
484491

485-
image = selected_gpu.images[image_idx - 1]
492+
image = selected_gpu.images[image_idx - 1]
486493

487494
# Get team ID from config if not provided
488495
if not team_id:
@@ -613,9 +620,10 @@ def terminate(pod_id: str) -> None:
613620
raise typer.Exit(1)
614621

615622

616-
@app.command()
617-
def ssh(pod_id: str) -> None:
618-
"""SSH into a pod using configured SSH key"""
623+
@app.command(name="connect")
624+
@app.command(name="ssh")
625+
def connect(pod_id: str) -> None:
626+
"""SSH / connect to a pod using configured SSH key"""
619627
try:
620628
base_client = APIClient()
621629
pods_client = PodsClient(base_client)
@@ -637,6 +645,11 @@ def ssh(pod_id: str) -> None:
637645
console.print(f"[red]SSH key not found at {ssh_key_path}[/red]")
638646
raise typer.Exit(1)
639647

648+
console.print(f"[blue]Using SSH key:[/blue] {ssh_key_path}")
649+
console.print(
650+
"[dim]To change SSH key path, use: prime config set-ssh-key-path[/dim]"
651+
)
652+
640653
ssh_conn = status.ssh_connection
641654
# Handle ssh_conn being either a string or list of strings
642655
connections: List[str] = []

0 commit comments

Comments
 (0)