Skip to content

Commit 733fb8c

Browse files
committed
runtimes: implement context parameter
Signed-off-by: Denys Fedoryshchenko <[email protected]>
1 parent 24dba2d commit 733fb8c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

kernelci/config/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class RuntimeLAVA(Runtime):
8383

8484
# This should be solved by dropping the "priority" attribute
8585
# pylint: disable=too-many-arguments
86-
def __init__(self, url, priority=None, priority_min=None,
86+
def __init__(self, url=None, priority=None, priority_min=None,
8787
priority_max=None, queue_timeout=None, notify=None,
8888
**kwargs):
8989
super().__init__(**kwargs)

kernelci/runtime/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ class Runtime(abc.ABC):
7575
TEMPLATES = ['config/runtime', '/etc/kernelci/runtime']
7676

7777
# pylint: disable=unused-argument
78-
def __init__(self, config, user=None, token=None, custom_template_dir=None):
78+
def __init__(self, config, user=None, token=None, custom_template_dir=None, context=None):
7979
"""A Runtime object can be used to run jobs in a runtime environment
8080
8181
*config* is a kernelci.config.runtime.Runtime object
8282
*custom_template_dir* is an optional custom directory for Jinja2 templates
83+
*context* is an optional context object for passing program context
8384
"""
8485
self._config = config
8586
self._templates = self.TEMPLATES.copy()
@@ -225,21 +226,23 @@ def wait(self, job_object):
225226
"""Wait for a job to complete and get the exit status code"""
226227

227228

228-
def get_runtime(config, user=None, token=None, custom_template_dir=None):
229+
def get_runtime(config, user=None, token=None, custom_template_dir=None, context=None):
229230
"""Get the Runtime object for a given runtime config.
230231
231232
*config* is a kernelci.config.runtime.Runtime object
232233
*user* is the name of the user to connect to the runtime
233234
*token* is the associated token to connect to the runtime
234235
*custom_template_dir* is an optional custom directory for Jinja2 templates
236+
*context* is an optional context object for passing program context
235237
"""
236238
module_name = '.'.join(['kernelci', 'runtime', config.lab_type])
237239
runtime_module = importlib.import_module(module_name)
238240
return runtime_module.get_runtime(config, user=user, token=token,
239-
custom_template_dir=custom_template_dir)
241+
custom_template_dir=custom_template_dir,
242+
context=context)
240243

241244

242-
def get_all_runtimes(runtime_configs, opts, custom_template_dir=None):
245+
def get_all_runtimes(runtime_configs, opts, custom_template_dir=None, context=None):
243246
"""Get all the Runtime objects based on the runtime configs and options
244247
245248
This will iterate over all the runtimes configs and yield a (name, runtime)
@@ -249,6 +252,7 @@ def get_all_runtimes(runtime_configs, opts, custom_template_dir=None):
249252
*runtime_configs* is the 'runtimes' config loaded from YAML
250253
*opts* is an Options object loaded from the CLI args and settings file
251254
*custom_template_dir* is an optional custom directory for Jinja2 templates
255+
*context* is an optional context object for passing program context
252256
"""
253257
for config_name, config in runtime_configs.items():
254258
section = ('runtime', config_name)
@@ -257,7 +261,8 @@ def get_all_runtimes(runtime_configs, opts, custom_template_dir=None):
257261
for opt in ('user', 'runtime_token')
258262
)
259263
runtime = get_runtime(config, user=user, token=token,
260-
custom_template_dir=custom_template_dir)
264+
custom_template_dir=custom_template_dir,
265+
context=context)
261266
yield config_name, runtime
262267

263268

0 commit comments

Comments
 (0)