@@ -235,9 +235,7 @@ def common_experiments_create_single_node_options(f):
235
235
@common_experiment_create_multi_node_options
236
236
def create_multi_node (api_key , ** kwargs ):
237
237
del_if_value_is_none (kwargs )
238
- experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST )
239
- if api_key :
240
- experiments_api .api_key = api_key
238
+ experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST , api_key = api_key )
241
239
experiments_commands .create_experiment (kwargs , api = experiments_api )
242
240
243
241
@@ -247,9 +245,7 @@ def create_multi_node(api_key, **kwargs):
247
245
def create_single_node (api_key , ** kwargs ):
248
246
kwargs ["experimentTypeId" ] = constants .ExperimentType .SINGLE_NODE
249
247
del_if_value_is_none (kwargs )
250
- experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST )
251
- if api_key :
252
- experiments_api .api_key = api_key
248
+ experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST , api_key = api_key )
253
249
experiments_commands .create_experiment (kwargs , api = experiments_api )
254
250
255
251
@@ -258,9 +254,7 @@ def create_single_node(api_key, **kwargs):
258
254
@common_experiment_create_multi_node_options
259
255
def create_and_start_multi_node (api_key , ** kwargs ):
260
256
del_if_value_is_none (kwargs )
261
- experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST )
262
- if api_key :
263
- experiments_api .api_key = api_key
257
+ experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST , api_key = api_key )
264
258
experiments_commands .create_and_start_experiment (kwargs , api = experiments_api )
265
259
266
260
@@ -270,9 +264,7 @@ def create_and_start_multi_node(api_key, **kwargs):
270
264
def create_and_start_single_node (api_key , ** kwargs ):
271
265
kwargs ["experimentTypeId" ] = constants .ExperimentType .SINGLE_NODE
272
266
del_if_value_is_none (kwargs )
273
- experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST )
274
- if api_key :
275
- experiments_api .api_key = api_key
267
+ experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST , api_key = api_key )
276
268
experiments_commands .create_and_start_experiment (kwargs , api = experiments_api )
277
269
278
270
@@ -283,9 +275,7 @@ def create_and_start_single_node(api_key, **kwargs):
283
275
"api_key" ,
284
276
)
285
277
def start (experiment_handle , api_key ):
286
- experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST )
287
- if api_key :
288
- experiments_api .api_key = api_key
278
+ experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST , api_key = api_key )
289
279
experiments_commands .start_experiment (experiment_handle , api = experiments_api )
290
280
291
281
@@ -296,9 +286,7 @@ def start(experiment_handle, api_key):
296
286
"api_key" ,
297
287
)
298
288
def stop (experiment_handle , api_key ):
299
- experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST )
300
- if api_key :
301
- experiments_api .api_key = api_key
289
+ experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST , api_key = api_key )
302
290
experiments_commands .stop_experiment (experiment_handle , api = experiments_api )
303
291
304
292
@@ -309,9 +297,7 @@ def stop(experiment_handle, api_key):
309
297
"api_key" ,
310
298
)
311
299
def list_experiments (project_handles , api_key ):
312
- experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST )
313
- if api_key :
314
- experiments_api .api_key = api_key
300
+ experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST , api_key = api_key )
315
301
command = experiments_commands .ListExperimentsCommand (api = experiments_api )
316
302
command .execute (project_handles )
317
303
@@ -323,9 +309,7 @@ def list_experiments(project_handles, api_key):
323
309
"api_key" ,
324
310
)
325
311
def get_experiment_details (experiment_handle , api_key ):
326
- experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST )
327
- if api_key :
328
- experiments_api .api_key = api_key
312
+ experiments_api = client .API (config .CONFIG_EXPERIMENTS_HOST , api_key = api_key )
329
313
experiments_commands .get_experiment_details (experiment_handle , api = experiments_api )
330
314
331
315
# TODO: delete experiment - not implemented in the api
0 commit comments