Ejemplo n.º 1
0
def home():
    user_details = get_user_details()

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    form = Computation()
    user_id = get_user_id(user_details[0])
    if form.validate_on_submit():  # this block of code is executed when browser sent POST request(user submitted form)
        try:
            DirectoryAndFileWriter.create_experiment(form, str(user_id))
            flash(current_app.config['EXPERIMENT_SUBMITTED'], "info")
            return redirect('/home')
        except NewComputationRequestSubmitError:
            flash(current_app.config['EXPERIMENT_SUBMISSION_FAILED'], "error")
            return redirect('/home')

    try:
        help_cookie = request.cookies["help"]
    except KeyError:
        help_cookie = "enabled"

    if is_user_registered(user_details[0]) and is_user_confirmed(user_details[0]):
        return render_template('home.html', form=form, username=get_user_username(user_details[0]), help=help_cookie, is_admin=is_user_admin(user_details[0]),
                               pages=DirectoryAndFileReader.get_pagination_controls_count(user_id),
                               comps=DirectoryAndFileReader.get_subset_of_computations_for_one_page(
                                   get_user_id(user_details[0]), 0, 'date', -1, {}))
    elif is_user_registered(user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))
Ejemplo n.º 2
0
def get_experiments(page, sort_option, sort_order):
    user_details = get_user_details()
    user_id = get_user_id(user_details[0])

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    elif is_user_registered(user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))

    return jsonify(comps=DirectoryAndFileReader.get_subset_of_computations_for_one_page(user_id, int(page), sort_option, int(sort_order), request.json),
                   pages=len(DirectoryAndFileReader.get_pagination_controls_count(computations=DirectoryAndFileReader.get_computations(user_id, sort_option, int(sort_order), request.json))))
Ejemplo n.º 3
0
def get_experiment_data():
    user_details = get_user_details()

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    elif is_user_registered(user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))

    user_id = request.args.get("user_id")
    comp_guid = request.args.get("comp_guid")
    json = jsonify(weights=DirectoryAndFileReader.get_weights(user_id, comp_guid),
                   computedCurves=DirectoryAndFileReader.get_computed_curves(user_id, comp_guid),
                   experimentData=DirectoryAndFileReader.get_experiment_data(user_id, comp_guid))
    return json
Ejemplo n.º 4
0
def view_experiment(user_id, comp_guid):
    user_details = get_user_details()

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    elif is_user_registered(user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))

    if not DirectoryAndFileReader.check_if_computation_exist(user_id, comp_guid):
        return render_template("unavailable.html", message="Requested computation results don't exist. Make sure the url is correct", icon="info.png")
    if not DirectoryAndFileReader.check_for_computation_results(user_id, comp_guid, DirectoryAndFileReader.get_computation_status(user_id, comp_guid)):
        return render_template("unavailable.html", message="Requested results cannot be displayed, because server has not finished the computation. Try again later", icon="gears.gif")
    DirectoryAndFileWriter.get_model_data(user_id, comp_guid)
    return render_template("view_experiment.html", username=user_details[1], is_admin=is_user_admin(user_details[0]),
                           best_results=DirectoryAndFileReader.get_best_solutions_of_computation(user_id, comp_guid),
                           computation_details=DirectoryAndFileReader.get_computation_parameters(user_id, comp_guid))
Ejemplo n.º 5
0
def get_experiments(page, sort_option, sort_order):
    user_details = get_user_details()
    user_id = get_user_id(user_details[0])

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    elif is_user_registered(
            user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))

    return jsonify(
        comps=DirectoryAndFileReader.get_subset_of_computations_for_one_page(
            user_id, int(page), sort_option, int(sort_order), request.json),
        pages=len(
            DirectoryAndFileReader.get_pagination_controls_count(
                computations=DirectoryAndFileReader.get_computations(
                    user_id, sort_option, int(sort_order), request.json))))
Ejemplo n.º 6
0
def get_experiment_data():
    user_details = get_user_details()

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    elif is_user_registered(
            user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))

    user_id = request.args.get("user_id")
    comp_guid = request.args.get("comp_guid")
    json = jsonify(weights=DirectoryAndFileReader.get_weights(
        user_id, comp_guid),
                   computedCurves=DirectoryAndFileReader.get_computed_curves(
                       user_id, comp_guid),
                   experimentData=DirectoryAndFileReader.get_experiment_data(
                       user_id, comp_guid))
    return json
Ejemplo n.º 7
0
def view_experiment(user_id, comp_guid):
    user_details = get_user_details()

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    elif is_user_registered(
            user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))

    if not DirectoryAndFileReader.check_if_computation_exist(
            user_id, comp_guid):
        return render_template(
            "unavailable.html",
            message=
            "Requested computation results don't exist. Make sure the url is correct",
            icon="info.png",
            username=get_user_username(user_details[0]))
    if not DirectoryAndFileReader.check_for_computation_results(
            user_id, comp_guid,
            DirectoryAndFileReader.get_computation_status(user_id, comp_guid)):
        return render_template(
            "unavailable.html",
            message=
            "Requested results cannot be displayed, because server has not finished the computation. Try again later",
            icon="info.png",
            username=get_user_username(user_details[0]))
    DirectoryAndFileWriter.move_model_and_experiment_data_to_upload_dir(
        user_id, comp_guid)
    return render_template(
        "view_experiment.html",
        username=get_user_username(user_details[0]),
        comp_guid=comp_guid,
        is_admin=is_user_admin(user_details[0]),
        best_results=DirectoryAndFileReader.get_best_solutions_of_computation(
            user_id, comp_guid),
        computation_details=DirectoryAndFileReader.get_computation_parameters(
            user_id, comp_guid))
Ejemplo n.º 8
0
def home():
    user_details = get_user_details()

    if not is_user_registered(user_details[0]):
        return redirect(url_for('userManagement.sign_up'))

    form = Computation()
    user_id = get_user_id(user_details[0])
    if form.validate_on_submit(
    ):  # this block of code is executed when browser sent POST request(user submitted form)
        try:
            DirectoryAndFileWriter.create_experiment(form, str(user_id))
            flash(current_app.config['EXPERIMENT_SUBMITTED'], "info")
            return redirect('/home')
        except NewComputationRequestSubmitError:
            flash(current_app.config['EXPERIMENT_SUBMISSION_FAILED'], "error")
            return redirect('/home')

    try:
        help_cookie = request.cookies["help"]
    except KeyError:
        help_cookie = "enabled"

    if is_user_registered(user_details[0]) and is_user_confirmed(
            user_details[0]):
        return render_template(
            'home.html',
            form=form,
            username=get_user_username(user_details[0]),
            help=help_cookie,
            is_admin=is_user_admin(user_details[0]),
            pages=DirectoryAndFileReader.get_pagination_controls_count(
                user_id),
            comps=DirectoryAndFileReader.
            get_subset_of_computations_for_one_page(
                get_user_id(user_details[0]), 0, 'date', -1, {}))
    elif is_user_registered(
            user_details[0]) and not is_user_confirmed(user_details[0]):
        return redirect(url_for('userManagement.unconfirmed'))