Skip to content

Commit

Permalink
fix failed test
Browse files Browse the repository at this point in the history
  • Loading branch information
ByronHsu committed Dec 6, 2024
1 parent 64ee666 commit 849755d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
37 changes: 20 additions & 17 deletions rust/py_test/test_launch_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def popen_launch_router(
try:
response = session.get(f"{base_url}/health")
if response.status_code == 200:
print(f"Router {base_url} is healthy")
return process
except requests.RequestException:
pass
Expand Down Expand Up @@ -102,6 +103,7 @@ def popen_launch_server(
try:
response = session.get(f"{base_url}/health")
if response.status_code == 200:
print(f"Server {base_url} is healthy")
return process
except requests.RequestException:
pass
Expand Down Expand Up @@ -129,22 +131,22 @@ def tearDownClass(cls):
for process in cls.other_process:
kill_process_tree(process.pid)

# def test_mmlu(self):
# args = SimpleNamespace(
# base_url=self.base_url,
# model=self.model,
# eval_name="mmlu",
# num_examples=64,
# num_threads=32,
# temperature=0.1,
# )

# metrics = run_eval(args)
# score = metrics["score"]
# THRESHOLD = 0.65
# passed = score >= THRESHOLD
# msg = f"MMLU test {'passed' if passed else 'failed'} with score {score:.3f} (threshold: {THRESHOLD})"
# self.assertGreaterEqual(score, THRESHOLD, msg)
def test_mmlu(self):
args = SimpleNamespace(
base_url=self.base_url,
model=self.model,
eval_name="mmlu",
num_examples=64,
num_threads=32,
temperature=0.1,
)

metrics = run_eval(args)
score = metrics["score"]
THRESHOLD = 0.65
passed = score >= THRESHOLD
msg = f"MMLU test {'passed' if passed else 'failed'} with score {score:.3f} (threshold: {THRESHOLD})"
self.assertGreaterEqual(score, THRESHOLD, msg)

def test_add_worker(self):
# 1. start a worker, and wait until it is healthy
Expand All @@ -157,8 +159,9 @@ def test_add_worker(self):
# 2. use /add_worker api to add it the the router
with requests.Session() as session:
response = session.post(
f"{self.base_url}/add_worker", json={"url": worker_url}
f"{self.base_url}/add_worker?url={worker_url}"
)
print(f"status code: {response.status_code}, response: {response.text}")
self.assertEqual(response.status_code, 200)
# 3. run mmlu
args = SimpleNamespace(
Expand Down
5 changes: 4 additions & 1 deletion rust/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ impl Router {
// For non-streaming requests, get response first
let response = match res.bytes().await {
Ok(body) => HttpResponse::build(status).body(body.to_vec()),
Err(_) => HttpResponse::InternalServerError().finish(),
Err(e) => {
let error_msg = format!("Failed to get response body: {}", e);
HttpResponse::InternalServerError().body(error_msg)
}
};

// Then decrement running queue counter if using CacheAware
Expand Down

0 comments on commit 849755d

Please sign in to comment.