Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Handle exception and kill restserver in nnictl (#2086)
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkSnail authored Feb 27, 2020
1 parent ff2728c commit ba5d18c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tools/nni_cmd/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,15 @@ def create_experiment(args):

nni_config.set_config('experimentConfig', experiment_config)
nni_config.set_config('restServerPort', args.port)
launch_experiment(args, experiment_config, 'new', config_file_name)
try:
launch_experiment(args, experiment_config, 'new', config_file_name)
except Exception as exception:
nni_config = Config(config_file_name)
restServerPid = nni_config.get_config('restServerPid')
if restServerPid:
kill_command(restServerPid)
print_error(exception)
exit(1)

def manage_stopped_experiment(args, mode):
'''view a stopped experiment'''
Expand Down Expand Up @@ -553,8 +561,16 @@ def manage_stopped_experiment(args, mode):
new_config_file_name = ''.join(random.sample(string.ascii_letters + string.digits, 8))
new_nni_config = Config(new_config_file_name)
new_nni_config.set_config('experimentConfig', experiment_config)
launch_experiment(args, experiment_config, mode, new_config_file_name, experiment_id)
new_nni_config.set_config('restServerPort', args.port)
try:
launch_experiment(args, experiment_config, mode, new_config_file_name, experiment_id)
except Exception as exception:
nni_config = Config(new_config_file_name)
restServerPid = nni_config.get_config('restServerPid')
if restServerPid:
kill_command(restServerPid)
print_error(exception)
exit(1)

def view_experiment(args):
'''view a stopped experiment'''
Expand Down

0 comments on commit ba5d18c

Please sign in to comment.