Exemplo n.º 1
0
def test_endpoints_multi_model_serving(endpoint, first_expected,
                                       second_expected, third_expected):
    app = compose_pandas(__name__, debug=True)
    client = TestClient(app)

    interp_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE,
               InterpolateModelServing.__name__))
    response = client.post(f"{interp_slugified}{endpoint}",
                           headers={"Accept": MediaTypes.JSON.value})
    assert response.status_code == 200
    assert response.json() == first_expected

    multi_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE,
               InterpolateMultiFrameModelServing.__name__))
    multi_response = client.post(f"{multi_slugified}{endpoint}",
                                 headers={"Accept": MediaTypes.JSON.value})
    assert multi_response.status_code == 200
    assert multi_response.json() == second_expected

    add_one_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE, AddOneModel.__name__))
    add_one_response = client.post(f"{add_one_slugified}{endpoint}",
                                   headers={"Accept": MediaTypes.JSON.value})
    assert add_one_response.status_code == 200
    assert add_one_response.json() == third_expected
Exemplo n.º 2
0
def test_index_multi_model_serving():
    app = compose_pandas(__name__, debug=True)
    client = TestClient(app)

    interp_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE,
               InterpolateModelServing.__name__))
    response = client.get(f"{interp_slugified}/")
    assert response.status_code == 200

    multi_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE,
               InterpolateMultiFrameModelServing.__name__))
    multi_response = client.get(f"{multi_slugified}/")
    assert multi_response.status_code == 200

    root_response = client.get("/")
    assert root_response.status_code == 200
Exemplo n.º 3
0
def test_multi_model_html_responses(endpoint):
    app = compose_pandas(__name__, debug=True)
    client = TestClient(app)

    interp_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE,
               InterpolateModelServing.__name__))
    response = client.get(f"{interp_slugified}{endpoint}",
                          headers={"Accept": MediaTypes.HTML.value})
    assert response.status_code == 200

    multi_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE,
               InterpolateMultiFrameModelServing.__name__))
    multi_response = client.get(f"{multi_slugified}{endpoint}",
                                headers={"Accept": MediaTypes.HTML.value})
    assert multi_response.status_code == 200

    add_one_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE, AddOneModel.__name__))
    add_one_response = client.get(f"{add_one_slugified}{endpoint}",
                                  headers={"Accept": MediaTypes.HTML.value})
    assert add_one_response.status_code == 200
Exemplo n.º 4
0
def test_predict_multi_model_serving():
    app = compose_pandas(__name__, debug=True)
    client = TestClient(app)
    interp_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE,
               InterpolateModelServing.__name__))
    response = client.post(
        f"{interp_slugified}/predict/",
        headers={"Accept": MediaTypes.JSON.value},
        json=interpolate_data,
    )
    assert response.status_code == 200
    assert response.json() == interpolate_result_data

    multi_slugified = slugify(
        re.sub(SLUGIFY_REGEX, SLUGIFY_REPLACE,
               InterpolateMultiFrameModelServing.__name__))
    multi_response = client.post(
        f"{multi_slugified}/predict/",
        headers={"Accept": MediaTypes.JSON.value},
        json=interpolate_multi_frame_data,
    )
    assert multi_response.status_code == 200
    assert multi_response.json() == interpolate_multi_frame_result_data
Exemplo n.º 5
0
from foxcross.pandas_serving import compose_pandas

app = compose_pandas()