Skip to content

Commit

Permalink
[AGENT-6113] Increase timeout and limit payload size of nginx (#4)
Browse files Browse the repository at this point in the history
* [AGENT-6113] Increase timeout and limit payload size of nginx

* update test
  • Loading branch information
dulcardo authored Aug 26, 2024
1 parent a64017b commit 2ba25c5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
2 changes: 1 addition & 1 deletion environments/java_codegen_monitoring/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
1.0.2
10 changes: 9 additions & 1 deletion environments/java_codegen_monitoring/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ events {
}

http {
log_format main '$remote_addr - $remote_user [$time_local] [$request] status: $status request_time: $request_time '
'bytes: $body_bytes_sent upstream: [$upstream_addr]';
access_log /dev/stdout main;
error_log /dev/stdout;

server {
listen 9001;
large_client_header_buffers 4 32k;
sendfile on;
keepalive_timeout 65;
client_max_body_size 20M;
client_max_body_size 1M;


# Remove v1 prefix from URL
Expand All @@ -21,6 +26,9 @@ http {
# Redirect to port 8080 where drum is running
location / {
proxy_pass http://localhost:8080/;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
proxy_connect_timeout 120s;
}
}
}
49 changes: 42 additions & 7 deletions tests/integration/test_make_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import contextlib
import logging
import time
from io import BytesIO

import pandas as pd
import pytest
Expand All @@ -19,6 +20,7 @@
SAP_MLOPS_INTEGRATION_IMAGE = (
"ghcr.io/datarobot-oss/mlops-sap-monitoring-scoring-code:latest"
)
MAX_ROWS_PER_REQUEST = 1000


def _wait_for_container_healthy(container, ping_url, timeout=100, interval=2):
Expand Down Expand Up @@ -96,14 +98,47 @@ def test_run_server(

base_url = "http://localhost:9001"
with run_sap_integration_image(env_vars, f"{base_url}/v1/ping/"):
# Make predictions
dataset = model_packages[model_package_id].get("model_dataset")
data_chunks = pd.read_csv(dataset, chunksize=MAX_ROWS_PER_REQUEST)

for chunk in data_chunks:
# Convert the chunk to a CSV byte stream
csv_chunk = BytesIO()
chunk.to_csv(csv_chunk, index=False)
csv_chunk.seek(0)

# Make predictions
response = requests.post(
f"{base_url}/v1/predict/",
data=csv_chunk,
)
assert response.status_code == 200

# assert number of predictions
predictions = response.json().get("predictions", [])
assert len(predictions) == len(chunk)


def test_run_server_large_request(
mock_dr_app,
mock_dr_app_port,
run_sap_integration_image,
model_packages,
):
env_vars = {
"MLOPS_MODEL_PACKAGE_ID": "10k_diabetes_package",
"TARGET_TYPE": "binary",
"DATAROBOT_ENDPOINT": f"http://host.docker.internal:{mock_dr_app_port}",
"DATAROBOT_API_TOKEN": "secret_token",
"POSITIVE_CLASS_LABEL": "True",
"NEGATIVE_CLASS_LABEL": "False",
}

base_url = "http://localhost:9001"
with run_sap_integration_image(env_vars, f"{base_url}/v1/ping/"):
# Make large number of predictions in a single request
dataset = model_packages["10k_diabetes_package"].get("model_dataset")
response = requests.post(
f"{base_url}/v1/predict/", data=dataset.open(mode="rb")
)
assert response.status_code == 200

# assert number of predictions
predictions = response.json().get("predictions", [])
dataset = pd.read_csv(dataset)
assert len(predictions) == len(dataset)
assert response.status_code == 413

0 comments on commit 2ba25c5

Please sign in to comment.