@@ -28,6 +28,7 @@ use scheduler::plugins::SchedulerPlugin;
2828use shared:: web3:: contracts:: core:: builder:: ContractBuilder ;
2929use shared:: web3:: contracts:: structs:: compute_pool:: PoolStatus ;
3030use shared:: web3:: wallet:: Wallet ;
31+ use status_update:: plugins:: node_groups:: NodeGroupConfiguration ;
3132use status_update:: plugins:: node_groups:: NodeGroupsPlugin ;
3233use status_update:: plugins:: StatusUpdatePlugin ;
3334use std:: sync:: Arc ;
@@ -115,14 +116,9 @@ struct Args {
115116 #[ arg( long, default_value = "" ) ]
116117 webhook_urls : Option < String > ,
117118
118- /// With basic group plugin
119- /// Only temporary setting - will be moved to proper plugin config
119+ /// Node group configurations in JSON format
120120 #[ arg( long) ]
121- with_basic_group_plugin : bool ,
122-
123- /// Group size
124- #[ arg( long, default_value = "4" ) ]
125- group_size : u32 ,
121+ node_group_configs : Option < String > ,
126122}
127123
128124#[ tokio:: main]
@@ -203,16 +199,26 @@ async fn main() -> Result<()> {
203199 let mut status_update_plugins: Vec < Box < dyn StatusUpdatePlugin > > = vec ! [ ] ;
204200 let mut node_groups_plugin: Option < Arc < NodeGroupsPlugin > > = None ;
205201
206- // Add group plugin if enabled
207- if args. with_basic_group_plugin {
208- let group_size: usize = args. group_size as usize ;
209- let group_plugin =
210- NodeGroupsPlugin :: new ( group_size, group_size, store. clone ( ) , group_store_context) ;
211- let status_group_plugin = group_plugin. clone ( ) ;
212- let group_plugin_for_server = group_plugin. clone ( ) ;
213- node_groups_plugin = Some ( Arc :: new ( group_plugin_for_server) ) ;
214- scheduler_plugins. push ( Box :: new ( group_plugin) ) ;
215- status_update_plugins. push ( Box :: new ( status_group_plugin) ) ;
202+ // This config loading is pretty ugly atm and should be optimized
203+ // Issue: https://github.com/PrimeIntellect-ai/protocol/issues/336
204+ if let Some ( configs_json) = args. node_group_configs {
205+ match serde_json:: from_str :: < Vec < NodeGroupConfiguration > > ( & configs_json) {
206+ Ok ( configs) if !configs. is_empty ( ) => {
207+ let group_plugin =
208+ NodeGroupsPlugin :: new ( configs, store. clone ( ) , group_store_context) ;
209+ let status_group_plugin = group_plugin. clone ( ) ;
210+ let group_plugin_for_server = group_plugin. clone ( ) ;
211+ node_groups_plugin = Some ( Arc :: new ( group_plugin_for_server) ) ;
212+ scheduler_plugins. push ( Box :: new ( group_plugin) ) ;
213+ status_update_plugins. push ( Box :: new ( status_group_plugin) ) ;
214+ }
215+ Ok ( _) => {
216+ info ! ( "No node group configurations provided, skipping plugin setup" ) ;
217+ }
218+ Err ( e) => {
219+ panic ! ( "Failed to parse node group configurations: {}" , e) ;
220+ }
221+ }
216222 }
217223
218224 let scheduler = Scheduler :: new ( store_context. clone ( ) , scheduler_plugins) ;
0 commit comments