예제 #1
0
def test_api_response_incorrect_range(data=input_data["incorrect_range"]):
    # whenever i am in "api_responses" and whenever i push the data in incorrect range
    # incorrect range for independent variables so at that time raise error (not in range)

    res = api_response(data)
    assert res["response"] == prediction_service.prediction.NotInRange(
    ).message
예제 #2
0
파일: app.py 프로젝트: vamsi1609/MLops
def index():
    if request.method == "POST":
        try:
            if request.form:
                data = dict(request.form).values()
                data = [list(map(float, data))]
                try:
                    data = check_(data)
                    response = predict(data)
                except NotInRange as e:
                    response = {
                        "the_exected_range": get_schema(),
                        "response": str(e)
                    }
                    return render_template("404.html", error={"error": e})
                return render_template("index.html", response=response)
            elif request.json:
                response = api_response(request)
                return jsonify(response)
        except Exception as e:
            print(e)
            error = {"error": e}
            return render_template("404.html", error=error)
        pass
    else:
        return render_template("index.html")
예제 #3
0
def index():
    if request.method == "POST":
        try:
            if request.form:
                data_req = dict(request.form)
                response = prediction.form_response(data_req)
                return render_template("index.html", response=response)
            elif request.json:
                response = prediction.api_response(request)
                return jsonify(response)
        except Exception as e:
            print(e)
            error = {"error": e}
            return render_template("404.html", error=error)
    else:
        return render_template("index.html")
예제 #4
0
def index():
    if request.method == "POST":
        try:
            if request.form:
                dict_req = dict(request.form)
                response = prediction.form_response(dict_req)
                return render_template("index.html", response=response)
            elif request.json:
                response = prediction.api_response(request.json)
                return jsonify(response)
        except Exception as e:
            #error = {"error":"Someting went wrong!! Try again"}
            error = {"error": e}
            return render_template("404.html", error=error)
    else:
        return render_template("index.html")
예제 #5
0
def index():

    if request.method == "POST":
        try:
            if request.form:
                path = request.form['filename']
                response = prediction.form_response(path)
                return render_template("index.html", response=response)
            elif request.json:
                response = prediction.api_response(request.json)
                return jsonify(response)

        except Exception as e:
            print(e)
            error = {"error": e}

            return render_template("404.html", error=error)
    else:
        return render_template("index.html")
예제 #6
0
def index():
    if request.method == 'POST':
        try:
            if request.form:
                data_dir = dict(request.form)
                response = prediction.form_response(data_dir)
                return render_template("index.html", response=response)

            elif request.json:
                response = prediction.api_response(request.json)
                return jsonify(response)

        except Exception as e:
            print(e)
            # error = {"error":"Something went wrong !! Try Again"}
            error = {"error": e}
            return render_template("404.html", error=error)
    else:
        return render_template("index.html")
예제 #7
0
파일: app.py 프로젝트: rajatbisoi/wineq
def index():

    if request.method == 'POST':

        try:
            if request.form:
                # data = [ i[1][0] for i in dict(request.form).items()]
                data_req = dict(request.form)
                # data = [list(map(float, data))]
                response = prediction.form_response(data_req)
                return render_template("index.html", response=response)
            elif request.json:
                response = prediction.api_response(request.json)
                return jsonify(response)

        except Exception as err:
            print(err)
            error = str(err)
            print(error)
            return render_template("404.html", error=err)
    else:
        return render_template('index.html')
예제 #8
0
def index():
    if request.method == "POST":
        try:
            if request.form:
                # data = dict(request.form).values()
                # data = [list(map(float, data))]
                # response = predict(data)
                data_req = dict(request.form)
                response = prediction.form_response(data_req)
                return render_template("index.html", response=response)

            elif request.json:
                # response = api_response(request)
                response = prediction.api_response(request.json)
                return jsonify(response)

        except Exception as e:
            print(e)
            # error = {"error": "something went wrong!! Try again"}
            error = {"error": e}
            return render_template("404.html", error=e)
    else:
        return render_template("index.html")
예제 #9
0
def test_form_response_incorrect_col(data=input_data["incorrect_col"]):
    res = api_response(data)
    assert res["response"] == prediction_service.prediction.NotInCols().message
예제 #10
0
def test_api_response_incorrect_range(data=input_data["incorrect_range"]):
    res = api_response(data)
    assert res["response"] == prediction_service.prediction.NotInRange(
    ).message
예제 #11
0
def test_api_response_correct_range(data=input_data["correct_range"]):
    res = api_response(data)
    assert TARGET_range["min"] <= res["response"] <= TARGET_range["max"]
예제 #12
0
def test_response_incorrect_col_response(data=input_data['incorrect_col']):
    res = api_response(data)
    assert res['response'] == prediction_service.prediction.NotInCols().message
예제 #13
0
def test_api_response_correct_range(data=input_data['correct_range']):
    res = api_response(data)
    assert TARGET_range['min'] <= res['response'] <= TARGET_range['max']
예제 #14
0
def test_api_response_correct_range(data=input_data["correct_range"]):
    res = api_response(data)
    # assert means i have a condition and that must be true
    assert TARGET_range["min"] <= res["response"] <= TARGET_range["max"]