@@ -55,7 +55,8 @@ def new(name, input_node_id, platform, # pylint: disable=too-many-arguments
55
55
if runtime not in configs ['runtimes' ]:
56
56
raise click .ClickException (f"Invalid runtime { runtime } " )
57
57
runtime = kernelci .runtime .get_runtime (
58
- configs ['runtimes' ][runtime ], token = secrets .api .runtime_token , custom_template_dir = config [0 ] if config else None )
58
+ configs ['runtimes' ][runtime ], token = secrets .api .runtime_token ,
59
+ custom_template_dir = config [0 ] if config else None )
59
60
job_node = helper .create_job_node (job_config , input_node ,
60
61
platform = platform_config , runtime = runtime )
61
62
if job_node :
@@ -107,16 +108,7 @@ def generate(node_id, # pylint: disable=too-many-arguments, too-many-locals
107
108
configs ['storage' ][storage ]
108
109
if storage else None
109
110
)
110
- if not runtime :
111
- raise click .ClickException ("No runtime provided (--runtime)" )
112
- runtimes_section = configs .get ('runtimes' , None )
113
- if runtimes_section is None :
114
- raise click .ClickException ("No runtimes section found in the config" )
115
- runtime_config = runtimes_section .get (runtime , None )
116
- if runtime_config is None :
117
- raise click .ClickException (f"Runtime { runtime } not found in the config" )
118
- runtime = kernelci .runtime .get_runtime (
119
- runtime_config , token = secrets .api .runtime_token , custom_template_dir = config [0 ] if config else None )
111
+ runtime = _get_runtime (runtime , config , secrets )
120
112
params = runtime .get_params (job , api .config )
121
113
if not params :
122
114
raise click .ClickException ("Invalid job parameters, aborting..." )
@@ -136,6 +128,23 @@ def generate(node_id, # pylint: disable=too-many-arguments, too-many-locals
136
128
click .echo (job_data )
137
129
138
130
131
+ def _get_runtime (runtime , config , secrets ):
132
+ if not runtime :
133
+ raise click .ClickException ("Runtime not specified, please provide --runtime argument" )
134
+ configs = kernelci .config .load (config )
135
+ runtime_section = configs .get ('runtimes' , None )
136
+ if runtime_section is None :
137
+ raise click .ClickException ("No runtime section found in the config" )
138
+ runtime_config = runtime_section .get (runtime , None )
139
+ if runtime_config is None :
140
+ raise click .ClickException (f"Runtime { runtime } not found in the config" )
141
+ runtime = kernelci .runtime .get_runtime (
142
+ runtime_config , token = secrets .api .runtime_token ,
143
+ custom_template_dir = config [0 ] if config else None
144
+ )
145
+ return runtime
146
+
147
+
139
148
@kci_job .command (secrets = True )
140
149
@click .argument ('job-path' )
141
150
@click .option ('--wait' , is_flag = True )
@@ -149,7 +158,8 @@ def submit(runtime, job_path, wait, # pylint: disable=too-many-arguments
149
158
configs = kernelci .config .load (config )
150
159
runtime_config = configs ['runtimes' ][runtime ]
151
160
runtime = kernelci .runtime .get_runtime (
152
- runtime_config , token = secrets .api .runtime_token , custom_template_dir = config [0 ] if config else None
161
+ runtime_config , token = secrets .api .runtime_token ,
162
+ custom_template_dir = config [0 ] if config else None
153
163
)
154
164
job = runtime .submit (job_path )
155
165
click .echo (runtime .get_job_id (job ))
0 commit comments