Skip to content

Commit e2275c3

Browse files
committed
Create found_gpus_by_model + fix typos
1 parent b635774 commit e2275c3

File tree

4 files changed

+37
-31
lines changed

4 files changed

+37
-31
lines changed

src/aleph_client/commands/help_strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
ROOTFS = (
2323
"Hash of the rootfs to use for your instance. Defaults to Ubuntu 22. You can also create your own rootfs and pin it"
2424
)
25-
COMPUTE_UNITS = "Number of compute units to allocate. Compute units correspond to a tier that includes vcpus, memory, disk and gpu presets. For reference, run: `aleph pricing for --help`"
25+
COMPUTE_UNITS = "Number of compute units to allocate. Compute units correspond to a tier that includes vcpus, memory, disk and gpu presets. For reference, run: `aleph pricing --help`"
2626
ROOTFS_SIZE = "Rootfs size in MiB to allocate"
2727
VCPUS = "Number of virtual CPUs to allocate"
2828
MEMORY = "Maximum memory (RAM) in MiB to allocate"
@@ -36,7 +36,7 @@
3636
CONFIDENTIAL_FIRMWARE_HASH = "Hash of the UEFI Firmware content, to validate measure (ignored if path is provided)"
3737
CONFIDENTIAL_FIRMWARE_PATH = "Path to the UEFI Firmware content, to validate measure (instead of the hash)"
3838
GPU_OPTION = "Launch an instance attaching a GPU to it"
39-
GPU_PREMIUM_OPTION = "Premium GPUs only (high VRAM)"
39+
GPU_PREMIUM_OPTION = "Use Premium GPUs (VRAM > 48GiB)"
4040
KEEP_SESSION = "Keeping the already initiated session"
4141
VM_SECRET = "Secret password to start the VM"
4242
CRN_URL_VM_DELETION = "Domain of the CRN where an associated VM is running. It ensures your VM will be stopped and erased on the CRN before the instance message is actually deleted"

src/aleph_client/commands/instance/__init__.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
from aleph_client.commands.utils import (
6969
filter_only_valid_messages,
7070
find_sevctl_or_exit,
71+
found_gpus_by_model,
7172
get_or_prompt_volumes,
7273
setup_logging,
7374
str_to_datetime,
@@ -326,28 +327,7 @@ async def create(
326327
if gpu:
327328
echo("Fetching available GPU list...")
328329
crn_list = await fetch_crn_list(latest_crn_version=True, ipv6=True, stream_address=True, gpu=True)
329-
found_gpu_models = {}
330-
for crn_ in crn_list:
331-
found_gpus: dict[str, dict[str, dict[str, int]]] = {}
332-
for gpu_ in crn_.compatible_available_gpus:
333-
model = gpu_["model"]
334-
device = gpu_["device_name"]
335-
if model not in found_gpus:
336-
found_gpus[model] = {device: {"count": 1, "on_crns": 1}}
337-
elif device not in found_gpus[model]:
338-
found_gpus[model][device] = {"count": 1, "on_crns": 1}
339-
else:
340-
found_gpus[model][device]["count"] += 1
341-
for model, devices in found_gpus.items():
342-
if model not in found_gpu_models:
343-
found_gpu_models[model] = devices
344-
else:
345-
for device, details in devices.items():
346-
if device not in found_gpu_models[model]:
347-
found_gpu_models[model][device] = details
348-
else:
349-
found_gpu_models[model][device]["count"] += details["count"]
350-
found_gpu_models[model][device]["on_crns"] += details["on_crns"]
330+
found_gpu_models = found_gpus_by_model(crn_list)
351331
premium = yes_no_input("Premium GPUs (high VRAM)?", default=False) if premium is None else premium
352332

353333
pricing = await fetch_pricing()
@@ -643,7 +623,7 @@ async def create(
643623
"Flow Distribution": "\n[bright_cyan]80% -> CRN wallet[/bright_cyan]"
644624
f"\n Address: {crn.stream_reward_address}\n Tx: {flow_hash_crn}"
645625
f"\n[bright_cyan]20% -> Community wallet[/bright_cyan]"
646-
f"\n Address:{community_wallet_address}\n Tx: {flow_hash_community}",
626+
f"\n Address: {community_wallet_address}\n Tx: {flow_hash_community}",
647627
}.items()
648628
)
649629
console.print(

src/aleph_client/commands/pricing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ def display_table_for(
168168
table.add_column("Tier", style="cyan")
169169
table.add_column("Compute Units", style="orchid")
170170
table.add_column("vCPUs", style="bright_cyan")
171-
table.add_column("RAM (Gib)", style="bright_cyan")
172-
table.add_column("Disk (Gib)", style="bright_cyan")
171+
table.add_column("RAM (GiB)", style="bright_cyan")
172+
table.add_column("Disk (GiB)", style="bright_cyan")
173173
if "model" in tiers[0]:
174174
table.add_column("GPU Model", style="orange1")
175175
if "vram" in tiers[0]:
176-
table.add_column("VRAM (Gib)", style="orange1")
176+
table.add_column("VRAM (GiB)", style="orange1")
177177
if "holding" in price_unit:
178178
table.add_column("$ALEPH (Holding)", style="red", justify="center")
179179
if "payg" in price_unit and pricing_entity in PAYG_GROUP:
@@ -245,15 +245,15 @@ def display_table_for(
245245

246246
extra_price_holding = (
247247
f"[red]{displayable_amount(Decimal(price_storage['holding'])*1024, decimals=5)}"
248-
" token/Gib[/red] (Holding) -or- "
248+
" token/GiB[/red] (Holding) -or- "
249249
if "holding" in price_storage
250250
else ""
251251
)
252252
infos = [
253253
Text.from_markup(
254254
f"Extra Volume Cost: {extra_price_holding}"
255255
f"[green]{displayable_amount(Decimal(price_storage['payg'])*1024*24, decimals=5)}"
256-
" token/Gib/day[/green] (Pay-As-You-Go)"
256+
" token/GiB/day[/green] (Pay-As-You-Go)"
257257
)
258258
]
259259
displayable_group = Group(
@@ -275,7 +275,7 @@ def display_table_for(
275275
f"{displayable_amount(Decimal(price_storage['holding']), decimals=5)}"
276276
" token/Mib[/bright_cyan] -or- [bright_cyan]"
277277
f"{displayable_amount(Decimal(price_storage['holding'])*1024, decimals=5)}"
278-
" token/Gib[/bright_cyan]"
278+
" token/GiB[/bright_cyan]"
279279
)
280280
)
281281
displayable_group = Group(

src/aleph_client/commands/utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,29 @@ def find_sevctl_or_exit() -> Path:
336336
echo("Instructions for setup https://docs.aleph.im/computing/confidential/requirements/")
337337
raise Exit(code=1)
338338
return Path(sevctl_path)
339+
340+
341+
def found_gpus_by_model(crn_list: list) -> dict[str, dict[str, dict[str, int]]]:
342+
found_gpu_models: dict[str, dict[str, dict[str, int]]] = {}
343+
for crn_ in crn_list:
344+
found_gpus: dict[str, dict[str, dict[str, int]]] = {}
345+
for gpu_ in crn_.compatible_available_gpus:
346+
model = gpu_["model"]
347+
device = gpu_["device_name"]
348+
if model not in found_gpus:
349+
found_gpus[model] = {device: {"count": 1, "on_crns": 1}}
350+
elif device not in found_gpus[model]:
351+
found_gpus[model][device] = {"count": 1, "on_crns": 1}
352+
else:
353+
found_gpus[model][device]["count"] += 1
354+
for model, devices in found_gpus.items():
355+
if model not in found_gpu_models:
356+
found_gpu_models[model] = devices
357+
else:
358+
for device, details in devices.items():
359+
if device not in found_gpu_models[model]:
360+
found_gpu_models[model][device] = details
361+
else:
362+
found_gpu_models[model][device]["count"] += details["count"]
363+
found_gpu_models[model][device]["on_crns"] += details["on_crns"]
364+
return found_gpu_models

0 commit comments

Comments
 (0)