Skip to content

Commit 7549568

Browse files
committed
Add --runtime-type parameter
To not add each lab into list and update k8s and docker-compose, we introduce new parameter - runtime-type. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent c0984c0 commit 7549568

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

src/scheduler.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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,34 @@ 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 = all)
201+
runtime_types: List of runtime types to filter by (empty = all)
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+
# If specific runtime names are provided, filter by name
209+
if runtimes:
210+
for name in runtimes:
211+
config = configs.get(name)
212+
if config:
213+
runtimes_configs[name] = config
214+
# If runtime types are provided, filter by type
215+
elif runtime_types:
216+
for name, config in configs.items():
217+
if config.lab_type in runtime_types:
218+
runtimes_configs[name] = config
219+
# If neither is provided, use all runtimes
220+
else:
221+
runtimes_configs = configs.copy()
222+
197223
return runtimes_configs
198224

199225
def _resolve_fragment_configs(self, fragment_names):
@@ -644,6 +670,11 @@ class cmd_loop(Command):
644670
'nargs': '*',
645671
'help': "Runtime environments to use, all by default",
646672
},
673+
{
674+
'name': '--runtime-type',
675+
'nargs': '*',
676+
'help': "Runtime types to use (lava, kubernetes, docker, shell, pull_labs)",
677+
},
647678
{
648679
'name': '--name',
649680
'help': "Service name used to create log file",

0 commit comments

Comments
 (0)