Skip to content

Commit bb5e3be

Browse files
authored
Fix: use arguments instead of get_closest_tier (#416)
* Fix: use arguments instead of get_closest_tier * Fix: ensure that hold can't use --vcpus or --memory or --rootfs_size upper than tier limit * fix: wrong display of vcpus on pricing display
1 parent f61e497 commit bb5e3be

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/aleph_client/commands/instance/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,13 @@ async def create(
390390
name = name or validated_prompt("Instance name", lambda x: x and len(x) < 65)
391391
specs = pricing.data[pricing_entity].get_services_specs(tier)
392392

393-
vcpus = specs.vcpus
394-
memory = specs.memory_mib
395-
disk_size = specs.disk_mib
393+
vcpus = vcpus if vcpus and payment_type != PaymentType.hold else specs.vcpus
394+
memory = memory if memory and payment_type != PaymentType.hold else specs.memory_mib
395+
disk_size = rootfs_size if rootfs_size and payment_type != PaymentType.hold else specs.disk_mib
396+
396397
gpu_model = specs.gpu_model
397398

398-
disk_size_info = f"Rootfs Size: {round(disk_size/1024, 2)} GiB (defaulted to included storage in tier)"
399+
disk_size_info = f"Rootfs Size: {round(disk_size / 1024, 2)} GiB (defaulted to included storage in tier)"
399400
if not isinstance(rootfs_size, int):
400401
rootfs_size = validated_int_prompt(
401402
"Custom Rootfs Size (MiB)",
@@ -405,7 +406,7 @@ async def create(
405406
)
406407
if rootfs_size > disk_size:
407408
disk_size = rootfs_size
408-
disk_size_info = f"Rootfs Size: {round(rootfs_size/1024, 2)} GiB (extended from included storage in tier)"
409+
disk_size_info = f"Rootfs Size: {round(rootfs_size / 1024, 2)} GiB (extended from included storage in tier)"
409410
echo(disk_size_info)
410411
volumes = []
411412
if any([persistent_volume, ephemeral_volume, immutable_volume]) or not skip_volume:
@@ -719,9 +720,9 @@ async def create(
719720
f"[orange3]{key}[/orange3]: {value}"
720721
for key, value in {
721722
"$ALEPH": f"[violet]{displayable_amount(required_tokens, decimals=8)}/sec"
722-
f" | {displayable_amount(3600*required_tokens, decimals=3)}/hour"
723-
f" | {displayable_amount(86400*required_tokens, decimals=3)}/day"
724-
f" | {displayable_amount(2628000*required_tokens, decimals=3)}/month[/violet]",
723+
f" | {displayable_amount(3600 * required_tokens, decimals=3)}/hour"
724+
f" | {displayable_amount(86400 * required_tokens, decimals=3)}/day"
725+
f" | {displayable_amount(2628000 * required_tokens, decimals=3)}/month[/violet]",
725726
"Flow Distribution": "\n[bright_cyan]80% ➜ CRN wallet[/bright_cyan]"
726727
f"\n Address: {crn_info.stream_reward_address}\n Tx: {flow_hash_crn}"
727728
f"\n[bright_cyan]20% ➜ Community wallet[/bright_cyan]"

src/aleph_client/commands/pricing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def build_storage_and_website(
8686
infos.append(
8787
Text.from_markup(
8888
"Service & Availability (Holding): [orange1]"
89-
f"{displayable_amount(price_dict.get('fixed'),decimals=3)}"
89+
f"{displayable_amount(price_dict.get('fixed'), decimals=3)}"
9090
" tokens[/orange1]\n"
9191
)
9292
)
@@ -172,7 +172,7 @@ def fill_tier(
172172
row = [
173173
tier_id,
174174
str(tier.compute_units),
175-
str(entity_info.compute_unit.vcpus),
175+
str(entity_info.compute_unit.vcpus * tier.compute_units),
176176
f"{entity_info.compute_unit.memory_mib * tier.compute_units / 1024:.0f}",
177177
f"{entity_info.compute_unit.disk_mib * tier.compute_units / 1024:.0f}",
178178
]
@@ -416,7 +416,6 @@ async def prices_for_service(
416416
# Fetch Current availibity
417417
network_gpu = None
418418
if (service in [GroupEntity.GPU, GroupEntity.ALL]) and with_current_availability:
419-
420419
crn_lists = await call_program_crn_list()
421420
network_gpu = crn_lists.find_gpu_on_network()
422421
if json:

0 commit comments

Comments
 (0)