@@ -235,9 +235,7 @@ def common_experiments_create_single_node_options(f):
235235@common_experiment_create_multi_node_options
236236def create_multi_node (api_key , ** kwargs ):
237237 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 )
241239 experiments_commands .create_experiment (kwargs , api = experiments_api )
242240
243241
@@ -247,9 +245,7 @@ def create_multi_node(api_key, **kwargs):
247245def create_single_node (api_key , ** kwargs ):
248246 kwargs ["experimentTypeId" ] = constants .ExperimentType .SINGLE_NODE
249247 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 )
253249 experiments_commands .create_experiment (kwargs , api = experiments_api )
254250
255251
@@ -258,9 +254,7 @@ def create_single_node(api_key, **kwargs):
258254@common_experiment_create_multi_node_options
259255def create_and_start_multi_node (api_key , ** kwargs ):
260256 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 )
264258 experiments_commands .create_and_start_experiment (kwargs , api = experiments_api )
265259
266260
@@ -270,9 +264,7 @@ def create_and_start_multi_node(api_key, **kwargs):
270264def create_and_start_single_node (api_key , ** kwargs ):
271265 kwargs ["experimentTypeId" ] = constants .ExperimentType .SINGLE_NODE
272266 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 )
276268 experiments_commands .create_and_start_experiment (kwargs , api = experiments_api )
277269
278270
@@ -283,9 +275,7 @@ def create_and_start_single_node(api_key, **kwargs):
283275 "api_key" ,
284276)
285277def 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 )
289279 experiments_commands .start_experiment (experiment_handle , api = experiments_api )
290280
291281
@@ -296,9 +286,7 @@ def start(experiment_handle, api_key):
296286 "api_key" ,
297287)
298288def 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 )
302290 experiments_commands .stop_experiment (experiment_handle , api = experiments_api )
303291
304292
@@ -309,9 +297,7 @@ def stop(experiment_handle, api_key):
309297 "api_key" ,
310298)
311299def 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 )
315301 command = experiments_commands .ListExperimentsCommand (api = experiments_api )
316302 command .execute (project_handles )
317303
@@ -323,9 +309,7 @@ def list_experiments(project_handles, api_key):
323309 "api_key" ,
324310)
325311def 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 )
329313 experiments_commands .get_experiment_details (experiment_handle , api = experiments_api )
330314
331315# TODO: delete experiment - not implemented in the api
0 commit comments