Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def teardown(self):
"""Terminate the Amazon instance"""
aws.terminate_ec2_instance(self.config, self.instance.id)
super().teardown()
Parameters
----------
config : dict
configuration
submission_id : int
submission id
"""
conf_aws = config[AWS_CONFIG_SECTION]
instance, = launch_ec2_instances(conf_aws, nb=1)
set_submission_state(config, submission_id, 'sent_to_training')
_wait_until_ready(config, instance.id)
train_on_existing_ec2_instance(config, instance.id, submission_id)
terminate_ec2_instance(conf_aws, instance.id)
set_predictions(config, submission_id, path)
set_time(config, submission_id, path)
set_scores(config, submission_id, path)
set_submission_state(config, submission_id, 'tested')
else:
logger.info('Training of "{}" failed'.format(label))
set_submission_state(
config, submission_id, 'training_error')
error_msg = _get_traceback(
_get_log_content(conf_aws, submission_name)
)
set_submission_error_msg(
config, submission_id, error_msg)
_run_hook(config, HOOK_FAILED_TRAINING, submission_id)
# training finished, so terminate the instance
terminate_ec2_instance(conf_aws, instance_id)
time.sleep(secs)