@@ -132,11 +132,15 @@ def __init__(self, configs, args):
132132 # Initialize runtimes with KContext
133133 # Get runtime names from KContext (parsed from CLI --runtimes argument)
134134 runtime_names = self ._kcontext .get_runtimes ()
135+ runtime_types = self ._kcontext .get_runtime_types ()
135136 self .log .info (f"Runtimes from KContext: { runtime_names } " )
137+ self .log .info (f"Runtime types from KContext: { runtime_types } " )
136138
137139 self .log .info (f"Initializing runtimes: { runtime_names } " )
138140
139- runtimes_configs = self ._get_runtimes_configs (configs ['runtimes' ], runtime_names )
141+ runtimes_configs = self ._get_runtimes_configs (
142+ configs ['runtimes' ], runtime_names , runtime_types
143+ )
140144
141145 # Use the original get_all_runtimes function which properly handles user/token extraction
142146 # but pass kcictx for new context-aware functionality
@@ -188,12 +192,43 @@ def __init__(self, configs, args):
188192 self ._storage = None
189193 self ._storage_config = None
190194
191- def _get_runtimes_configs (self , configs , runtimes ):
195+ def _get_runtimes_configs (self , configs , runtimes , runtime_types = None ):
196+ """Get runtime configurations filtered by name and/or type.
197+
198+ Args:
199+ configs: Dictionary of all runtime configurations
200+ runtimes: List of runtime names to filter by (empty/None = no name filter)
201+ runtime_types: List of runtime types to filter by (empty/None = no type filter)
202+
203+ Returns:
204+ Dictionary of filtered runtime configurations
205+ """
192206 runtimes_configs = {}
193- for name in runtimes :
194- config = configs .get (name )
195- if config :
196- runtimes_configs [name ] = config
207+
208+ # Check if both filters are provided
209+ if runtimes and runtime_types :
210+ self .log .warning (
211+ "Both --runtimes and --runtime-type specified. "
212+ "Using --runtimes (--runtime-type will be ignored)"
213+ )
214+
215+ # Filter by runtime name if provided
216+ if runtimes :
217+ self .log .info (f"Filtering runtimes by name: { runtimes } " )
218+ for name in runtimes :
219+ config = configs .get (name )
220+ if config :
221+ runtimes_configs [name ] = config
222+ else :
223+ self .log .warning (f"Runtime '{ name } ' not found in configuration" )
224+ # Otherwise filter by runtime type if provided
225+ elif runtime_types :
226+ self .log .info (f"Filtering runtimes by type: { runtime_types } " )
227+ for name , config in configs .items ():
228+ if config .lab_type in runtime_types :
229+ runtimes_configs [name ] = config
230+
231+ self .log .info (f"Selected { len (runtimes_configs )} runtime(s): { list (runtimes_configs .keys ())} " )
197232 return runtimes_configs
198233
199234 def _resolve_fragment_configs (self , fragment_names ):
@@ -644,6 +679,11 @@ class cmd_loop(Command):
644679 'nargs' : '*' ,
645680 'help' : "Runtime environments to use, all by default" ,
646681 },
682+ {
683+ 'name' : '--runtime-type' ,
684+ 'nargs' : '*' ,
685+ 'help' : "Runtime types to use (lava, kubernetes, docker, shell, pull_labs)" ,
686+ },
647687 {
648688 'name' : '--name' ,
649689 'help' : "Service name used to create log file" ,
0 commit comments