From d28bf42f6107733d8744c45b3b50b007ede8ba77 Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Thu, 11 Dec 2025 15:31:13 +0200 Subject: [PATCH] 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 --- src/scheduler.py | 56 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/src/scheduler.py b/src/scheduler.py index fbf7c00bb..a76322f42 100755 --- a/src/scheduler.py +++ b/src/scheduler.py @@ -132,11 +132,15 @@ def __init__(self, configs, args): # Initialize runtimes with KContext # Get runtime names from KContext (parsed from CLI --runtimes argument) runtime_names = self._kcontext.get_runtimes() + runtime_types = self._kcontext.get_runtime_types() self.log.info(f"Runtimes from KContext: {runtime_names}") + self.log.info(f"Runtime types from KContext: {runtime_types}") self.log.info(f"Initializing runtimes: {runtime_names}") - runtimes_configs = self._get_runtimes_configs(configs['runtimes'], runtime_names) + runtimes_configs = self._get_runtimes_configs( + configs['runtimes'], runtime_names, runtime_types + ) # Use the original get_all_runtimes function which properly handles user/token extraction # but pass kcictx for new context-aware functionality @@ -188,12 +192,47 @@ def __init__(self, configs, args): self._storage = None self._storage_config = None - def _get_runtimes_configs(self, configs, runtimes): + def _get_runtimes_configs(self, configs, runtimes, runtime_types=None): + """Get runtime configurations filtered by name and/or type. + + Args: + configs: Dictionary of all runtime configurations + runtimes: List of runtime names to filter by (empty/None = no name filter) + runtime_types: List of runtime types to filter by (empty/None = no type filter) + + Returns: + Dictionary of filtered runtime configurations + """ runtimes_configs = {} - for name in runtimes: - config = configs.get(name) - if config: - runtimes_configs[name] = config + + # Check if both filters are provided + if runtimes and runtime_types: + self.log.warning( + "Both --runtimes and --runtime-type specified. " + "Using --runtimes (--runtime-type will be ignored)" + ) + + # Filter by runtime name if provided + if runtimes: + self.log.info(f"Filtering runtimes by name: {runtimes}") + for name in runtimes: + config = configs.get(name) + if config: + runtimes_configs[name] = config + else: + self.log.warning(f"Runtime '{name}' not found in configuration") + # Otherwise filter by runtime type if provided + elif runtime_types: + self.log.info(f"Filtering runtimes by type: {runtime_types}") + for name, config in configs.items(): + if config.lab_type in runtime_types: + runtimes_configs[name] = config + # If neither is provided, use all runtimes + else: + self.log.info("No runtime filters specified, using all available runtimes") + runtimes_configs = configs.copy() + + self.log.info(f"Selected {len(runtimes_configs)} runtime(s): {list(runtimes_configs.keys())}") return runtimes_configs def _resolve_fragment_configs(self, fragment_names): @@ -644,6 +683,11 @@ class cmd_loop(Command): 'nargs': '*', 'help': "Runtime environments to use, all by default", }, + { + 'name': '--runtime-type', + 'nargs': '*', + 'help': "Runtime types to use (lava, kubernetes, docker, shell, pull_labs)", + }, { 'name': '--name', 'help': "Service name used to create log file",