66import shutil
77from decimal import Decimal
88from pathlib import Path
9- from typing import Annotated , Any , Optional , Union
9+ from typing import Annotated , Any , Optional
1010
1111import aiohttp
1212import typer
3030)
3131from aleph .sdk .query .responses import PriceResponse
3232from aleph .sdk .types import (
33- CrnExecutionV1 ,
34- CrnExecutionV2 ,
3533 InstanceAllocationsInfo ,
3634 InstanceWithScheduler ,
3735 PortFlags ,
@@ -470,7 +468,6 @@ async def create(
470468 echo (f"Failed to fetch credit info, error: { e } " )
471469 raise typer .Exit (code = 1 ) from e
472470
473- stream_reward_address = None
474471 crn , crn_info , gpu_id = None , None , None
475472 if is_stream or confidential or gpu or is_credit :
476473 if crn_url :
@@ -610,7 +607,7 @@ async def create(
610607
611608 payment = Payment (
612609 chain = payment_chain ,
613- receiver = stream_reward_address if stream_reward_address else None ,
610+ receiver = crn_info . stream_reward_address if crn_info and crn_info . stream_reward_address else None ,
614611 type = payment_type ,
615612 )
616613
@@ -636,7 +633,7 @@ async def create(
636633 try :
637634 content = make_instance_content (** content_dict )
638635 price : PriceResponse = await client .get_estimated_price (content )
639- required_tokens = Decimal (price .required_tokens )
636+ required_tokens = price . required_tokens if price . cost is None else Decimal (price .cost )
640637 except Exception as e :
641638 echo (f"Failed to estimate instance cost, error: { e } " )
642639 raise typer .Exit (code = 1 ) from e
@@ -839,7 +836,6 @@ async def delete(
839836 existing_message : InstanceMessage = await client .get_message (
840837 item_hash = ItemHash (item_hash ), message_type = InstanceMessage
841838 )
842-
843839 except MessageNotFoundError :
844840 echo ("Instance does not exist" )
845841 raise typer .Exit (code = 1 ) from None
@@ -872,11 +868,6 @@ async def delete(
872868 if isinstance (instance_info , InstanceWithScheduler ):
873869 echo (f"Instance { item_hash } was auto-scheduled, VM will be erased automatically." )
874870 elif instance_info is not None and hasattr (instance_info , "crn_url" ) and instance_info .crn_url :
875- execution : Optional [Union [CrnExecutionV1 , CrnExecutionV2 ]] = await client .crn .get_vm (
876- instance_info .crn_url , item_hash = ItemHash (item_hash )
877- )
878- if not execution :
879- echo ("VM is not running or CRN not accessible, Skipping ..." )
880871 try :
881872 async with VmClient (account , instance_info .crn_url ) as manager :
882873 status , _ = await manager .erase_instance (vm_id = item_hash )
0 commit comments