How to use ramp-engine - 10 common examples

To help you get started, we’ve selected a few ramp-engine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paris-saclay-cds / ramp-board / ramp-engine / ramp_engine / aws / aws_train.py View on Github external
assert submission_name.startswith('submission_')
            submission_id = int(submission_name[11:])
            submission = get_submission_by_id(config, submission_id)
            label = '{}_{}'.format(submission_id, submission.name)
            state = get_submission_state(config, submission_id)
            submissions_dir = os.path.split(submission.path)[0]
            if state == 'sent_to_training':
                exit_status = upload_submission(
                    conf_aws, instance_id, submission_name, submissions_dir)
                if exit_status != 0:
                    logger.error(
                        'Cannot upload submission "{}"'
                        ', an error occured'.format(label))
                    continue
                # start training HERE
                exit_status = launch_train(
                    conf_aws, instance_id, submission_name)
                if exit_status != 0:
                    logger.error(
                        'Cannot start training of submission "{}"'
                        ', an error occured.'.format(label))
                    continue
                set_submission_state(config, submission_id, 'training')
                _run_hook(config, HOOK_START_TRAINING, submission_id)

            elif state == 'training':
                # in any case (successful training or not)
                # download the log
                download_log(conf_aws, instance_id, submission_name)
                if _training_finished(conf_aws, instance_id, submission_name):
                    logger.info(
                        'Training of "{}" finished, checking '
github paris-saclay-cds / ramp-board / ramp-engine / ramp_engine / aws / aws_train.py View on Github external
# if 'submission_id' not in tags:  # no longer added to tags
            #     continue
            if tags.get('event_name') != event_name:
                continue
            if 'train_loop' not in tags:
                continue
            # Process each instance
            submission_name = tags['Name']
            assert submission_name.startswith('submission_')
            submission_id = int(submission_name[11:])
            submission = get_submission_by_id(config, submission_id)
            label = '{}_{}'.format(submission_id, submission.name)
            state = get_submission_state(config, submission_id)
            submissions_dir = os.path.split(submission.path)[0]
            if state == 'sent_to_training':
                exit_status = upload_submission(
                    conf_aws, instance_id, submission_name, submissions_dir)
                if exit_status != 0:
                    logger.error(
                        'Cannot upload submission "{}"'
                        ', an error occured'.format(label))
                    continue
                # start training HERE
                exit_status = launch_train(
                    conf_aws, instance_id, submission_name)
                if exit_status != 0:
                    logger.error(
                        'Cannot start training of submission "{}"'
                        ', an error occured.'.format(label))
                    continue
                set_submission_state(config, submission_id, 'training')
                _run_hook(config, HOOK_START_TRAINING, submission_id)
github paris-saclay-cds / ramp-board / ramp-engine / rampbkd / model.py View on Github external
def path(self):
        return os.path.join(
            config.get_deployment_path(),
            'submissions',
            'submission_' + '{0:09d}'.format(self.id))
github paris-saclay-cds / ramp-board / ramp-engine / rampbkd / model.py View on Github external
def get_train_data(self):
        path = os.path.join(config.get_deployment_path(),
                            'ramp-data',
                            self.name)
        return self.module.get_train_data(path=path)
github paris-saclay-cds / ramp-board / ramp-engine / rampbkd / model.py View on Github external
def get_test_data(self):
        path = os.path.join(config.get_deployment_path(),
                            'ramp-data',
                            self.name)
        return self.module.get_test_data(path=path)
github paris-saclay-cds / ramp-board / ramp-engine / rampbkd / model.py View on Github external
def module(self):
        return imp.load_source(
            '', os.path.join(config.get_deployment_path(),
                             'ramp-kits',
                             self.name,
                             'problem.py'))
github paris-saclay-cds / ramp-board / ramp-engine / ramp_engine / aws / aws_train.py View on Github external
logger.info('Downloading predictions of : "{}"'.format(label))
        predictions_folder_path = download_predictions(
            conf_aws, instance_id, submission_id)
        set_predictions(config, submission_id, predictions_folder_path)
        set_time(config, submission_id, predictions_folder_path)
        set_scores(config, submission_id, predictions_folder_path)
        set_submission_state(config, submission_id, 'tested')
        logger.info('Scoring "{}"'.format(label))
        score_submission(config, submission_id)
        _run_hook(config, HOOK_SUCCESSFUL_TRAINING, submission_id)
    else:
        logger.info('Training of "{}" in "{}" failed'.format(
            label, instance_id))
        set_submission_state(config, submission_id, 'training_error')
        error_msg = _get_traceback(
            _get_log_content(conf_aws, submission_id))
        set_submission_error_msg(config, submission_id, error_msg)
        _run_hook(config, HOOK_FAILED_TRAINING, submission_id)
github paris-saclay-cds / ramp-board / ramp-engine / ramp_engine / aws / aws_train.py View on Github external
)

                        logger.info('Downloading the predictions of "{}"'
                                    .format(label))
                        path = download_predictions(
                            conf_aws, instance_id, submission_name)
                        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)
github paris-saclay-cds / ramp-board / ramp-engine / ramp_engine / aws / worker.py View on Github external
if self.status != 'finished':
            raise ValueError("Cannot collect results if worker is not"
                             "'running' or 'finished'")

        logger.info("Collecting submission '{}'".format(self.submission))
        aws.download_log(self.config, self.instance.id, self.submission)

        if aws._training_successful(
                self.config, self.instance.id, self.submission):
            _ = aws.download_predictions(  # noqa
                self.config, self.instance.id, self.submission)
            self.status = 'collected'
            exit_status, error_msg = 0, ''
        else:
            error_msg = _get_traceback(
                aws._get_log_content(self.config, self.submission))
            self.status = 'collected'
            exit_status = 1
        logger.info(repr(self))
        return exit_status, error_msg
github paris-saclay-cds / ramp-board / ramp-engine / ramp_engine / aws / aws_train.py View on Github external
5) download th log
        6) set the predictions in the database
        7) score the submission
    """
    conf_aws = config[AWS_CONFIG_SECTION]
    upload_submission(conf_aws, instance_id, submission_id)
    launch_train(conf_aws, instance_id, submission_id)
    set_submission_state(config, submission_id, 'training')
    _run_hook(config, HOOK_START_TRAINING, submission_id)
    _wait_until_train_finished(conf_aws, instance_id, submission_id)
    download_log(conf_aws, instance_id, submission_id)

    label = _get_submission_label_by_id(config, submission_id)
    submission = get_submission_by_id(config, submission_id)
    actual_nb_folds = get_event_nb_folds(config, submission.event.name)
    if _training_successful(conf_aws, instance_id, submission_id,
                            actual_nb_folds):
        logger.info('Training of "{}" was successful'.format(
            label, instance_id))
        if conf_aws[MEMORY_PROFILING_FIELD]:
            logger.info('Download max ram usage info of "{}"'.format(label))
            download_mprof_data(conf_aws, instance_id, submission_id)
            max_ram = _get_submission_max_ram(conf_aws, submission_id)
            logger.info('Max ram usage of "{}": {}MB'.format(label, max_ram))
            set_submission_max_ram(config, submission_id, max_ram)

        logger.info('Downloading predictions of : "{}"'.format(label))
        predictions_folder_path = download_predictions(
            conf_aws, instance_id, submission_id)
        set_predictions(config, submission_id, predictions_folder_path)
        set_time(config, submission_id, predictions_folder_path)
        set_scores(config, submission_id, predictions_folder_path)