def results_view():
    if not engine_interface.is_experiment_active():
        return redirect(url_for('dashboard_view'))

    return render_template(
        'view/results_view.html',
        is_experiment_active=engine_interface.is_experiment_active())
def add_blocks_view():
    if not engine_interface.is_experiment_active():
        return redirect(url_for('dashboard_view'))

    form = HyperparameterSettingForm()

    if form.validate_on_submit():

        PARAMETERS_DICT = dict(optimizer=form.optimizer.getData(),
                               init_mode=form.init_mode.getData(),
                               batch_size=form.batch.getData(),
                               epochs=form.epoch.getData(),
                               learn_rate=form.learn_rate.getData(),
                               momentum=form.momentum.getData(),
                               n_neurons_per_layer=[[12, 8, 8, 8, 8, 8]])

        engine_interface.add_blocks_to_queue(PARAMETERS_DICT,
                                             split_size=form.split_size.data,
                                             batchMode=form.batchMode())

        if form.batchMode():
            flash("Batch of blocks added")
        else:
            flash("Sigle block added")

        return redirect(url_for('execution_queue_view'))

    return render_template(
        'view/add_blocks_view.html',
        form=form,
        is_experiment_active=engine_interface.is_experiment_active())
def block_queue(experiment_id=None):
    if not engine_interface.is_experiment_active():
        return jsonify({"status": "error"})

    queue = engine_interface.get_queue_data_as_table()

    if queue is not None:
        d = queue
    else:
        d = {}

    return jsonify(d)
def block_results(experiment_id=None):
    if not engine_interface.is_experiment_active():
        return jsonify({"status": "error"})

    results = engine_interface.get_blocks_results()

    if results is not None:
        d = results
    else:
        d = {}

    return jsonify(d)
def internal_error(error):
    # db.session.rollback()
    return render_template(
        '500.html',
        is_experiment_active=engine_interface.is_experiment_active()), 500
def not_found_error(error):
    return render_template(
        '404.html',
        is_experiment_active=engine_interface.is_experiment_active()), 404
def dashboard_view():
    return render_template(
        'view/dashboard_view.html',
        is_experiment_active=engine_interface.is_experiment_active())
def remove_block(experiment_id=None, block_id=None):
    if not engine_interface.is_experiment_active():
        return jsonify({"status": "error"})

    engine_interface.remove_block(block_id)
    return jsonify({"status": "success"})