1111from textual .widgets import DataTable , Footer , Label , ProgressBar
1212from textual .widgets ._data_table import RowKey
1313
14- from aleph_client .commands .instance .network import fetch_crn_list
14+ from aleph_client .commands .instance .network import (
15+ fetch_crn_list ,
16+ fetch_latest_crn_version ,
17+ )
1518from aleph_client .commands .node import _format_score
1619from aleph_client .models import CRNInfo
1720
@@ -22,6 +25,7 @@ class CRNTable(App[CRNInfo]):
2225 table : DataTable
2326 tasks : set [asyncio .Task ] = set ()
2427 crns : dict [RowKey , CRNInfo ] = {}
28+ last_crn_version : str
2529 total_crns : int
2630 active_crns : int = 0
2731 filtered_crns : int = 0
@@ -50,12 +54,14 @@ class CRNTable(App[CRNInfo]):
5054
5155 def __init__ (
5256 self ,
57+ only_latest_crn_version : bool = False ,
5358 only_reward_address : bool = False ,
5459 only_qemu : bool = False ,
5560 only_confidentials : bool = False ,
5661 only_gpu : bool = False ,
5762 ):
5863 super ().__init__ ()
64+ self .only_latest_crn_version = only_latest_crn_version
5965 self .only_reward_address = only_reward_address
6066 self .only_qemu = only_qemu
6167 self .only_confidentials = only_confidentials
@@ -94,8 +100,8 @@ async def on_mount(self):
94100 task .add_done_callback (self .tasks .discard )
95101
96102 async def fetch_node_list (self ):
97- crn_list : list [ CRNInfo ] = await fetch_crn_list (ipv6 = False , stream_address = False )
98- self .crns : dict [ RowKey , CRNInfo ] = { RowKey ( crn . hash ): crn for crn in crn_list }
103+ self . crns : dict [ RowKey , CRNInfo ] = { RowKey ( crn . hash ): crn for crn in await fetch_crn_list ()}
104+ self .last_crn_version = await fetch_latest_crn_version ()
99105
100106 # Initialize the progress bar
101107 self .total_crns = len (self .crns )
@@ -112,6 +118,10 @@ async def fetch_node_list(self):
112118
113119 async def add_crn_info (self , crn : CRNInfo ):
114120 self .active_crns += 1
121+ # Skip CRNs with legacy version
122+ if self .only_latest_crn_version and crn .version < self .last_crn_version :
123+ logger .debug (f"Skipping CRN { crn .hash } , legacy version" )
124+ return
115125 # Skip CRNs without machine usage
116126 if not crn .machine_usage :
117127 logger .debug (f"Skipping CRN { crn .hash } , no machine usage" )
@@ -133,11 +143,7 @@ async def add_crn_info(self, crn: CRNInfo):
133143 logger .debug (f"Skipping CRN { crn .hash } , no confidential support" )
134144 return
135145 # Skip non-gpu CRNs if only-gpu is set
136- if (
137- self .only_gpu
138- and not crn .gpu_support
139- and not (crn .machine_usage .gpu and len (crn .machine_usage .gpu .available_devices ) < 1 )
140- ):
146+ if self .only_gpu and not (crn .gpu_support and crn .compatible_available_gpus ):
141147 logger .debug (f"Skipping CRN { crn .hash } , no GPU support or without GPU available" )
142148 return
143149 self .filtered_crns += 1
0 commit comments