44from aleph_message .models import InstanceMessage , ItemHash , MessageType , PaymentType
55from aleph_message .status import MessageStatus
66
7+ from aleph .sdk .client .services .crn import CrnList
78from aleph .sdk .query .filters import MessageFilter
89from aleph .sdk .query .responses import MessagesResponse
910
@@ -47,7 +48,7 @@ async def get_name_of_executable(self, item_hash: ItemHash) -> Optional[str]:
4748 return None
4849
4950 async def get_instance_allocation_info (
50- self , msg : InstanceMessage , crn_list : dict
51+ self , msg : InstanceMessage , crn_list : CrnList
5152 ) -> Tuple [InstanceMessage , Union [InstanceManual , InstanceWithScheduler ]]:
5253 vm_hash = msg .item_hash
5354 payment_type = safe_getattr (msg , "content.payment.type.value" )
@@ -62,12 +63,8 @@ async def get_instance_allocation_info(
6263 info = InstanceWithScheduler (source = "scheduler" , allocations = alloc )
6364 else :
6465 crn_hash = safe_getattr (msg , "content.requirements.node.node_hash" )
65- if isinstance (crn_list , list ):
66- node = next ((n for n in crn_list if n .get ("hash" ) == crn_hash ), None )
67- url = sanitize_url (node .get ("address" )) if node else ""
68- else :
69- node = crn_list .get (crn_hash )
70- url = sanitize_url (node .get ("address" )) if node else ""
66+ node = crn_list .find_crn_by_hash (crn_hash )
67+ url = sanitize_url (node .address ) if node else ""
7168
7269 info = InstanceManual (source = "manual" , crn_url = url )
7370 return msg , info
@@ -84,8 +81,7 @@ async def get_instances(self, address: str) -> List[InstanceMessage]:
8481 return resp .messages
8582
8683 async def get_instances_allocations (self , messages_list , only_processed = True ):
87- crn_list_response = await self ._client .crn .get_crns_list ()
88- crn_list = crn_list_response .get ("crns" , {})
84+ crn_list = await self ._client .crn .get_crns_list (only_active = False )
8985
9086 tasks = []
9187 for msg in messages_list :
0 commit comments