[router] clean up lint warnings with clippy execution (#9201)

This commit is contained in:
Jeff Nettleton
2025-08-15 11:01:21 -07:00
committed by GitHub
parent 21b8846066
commit d7e38b2f6d
10 changed files with 39 additions and 38 deletions

View File

@@ -232,7 +232,7 @@ impl PDRouter {
})?;
// Check if already exists
if workers.iter().any(|w| w.url() == &url) {
if workers.iter().any(|w| w.url() == url) {
return Err(PDRouterError::WorkerAlreadyExists { url: url.clone() });
}
@@ -271,7 +271,7 @@ impl PDRouter {
})?;
// Check if already exists
if workers.iter().any(|w| w.url() == &url) {
if workers.iter().any(|w| w.url() == url) {
return Err(PDRouterError::WorkerAlreadyExists { url: url.clone() });
}
@@ -532,11 +532,9 @@ impl PDRouter {
// Helper to determine batch size from a GenerateRequest
fn get_generate_batch_size(req: &GenerateRequest) -> Option<usize> {
// Check prompt array
if let Some(prompt) = &req.prompt {
if let crate::openai_api_types::StringOrArray::Array(arr) = prompt {
if !arr.is_empty() {
return Some(arr.len());
}
if let Some(crate::openai_api_types::StringOrArray::Array(arr)) = &req.prompt {
if !arr.is_empty() {
return Some(arr.len());
}
}
// Check text array
@@ -978,14 +976,14 @@ impl PDRouter {
// Select workers using helper function
let prefill = Self::pick_worker_by_policy(
&*prefill_workers,
&prefill_workers,
&*self.prefill_policy,
request_text,
"prefill",
)?;
let decode = Self::pick_worker_by_policy(
&*decode_workers,
&decode_workers,
&*self.decode_policy,
request_text,
"decode",
@@ -1488,7 +1486,7 @@ impl RouterTrait for PDRouter {
let (prefill_result, decode_result) = tokio::join!(
self.client.get(&prefill_url).send(),
self.client
.get(&format!("{}/health_generate", decode.url()))
.get(format!("{}/health_generate", decode.url()))
.send()
);

View File

@@ -276,7 +276,7 @@ impl Router {
fn get_worker_dp_size(worker_url: &str, api_key: &Option<String>) -> Result<usize, String> {
let sync_client = reqwest::blocking::Client::new();
let mut req_builder = sync_client.get(&format!("{}/get_server_info", worker_url));
let mut req_builder = sync_client.get(format!("{}/get_server_info", worker_url));
if let Some(key) = api_key {
req_builder = req_builder.bearer_auth(key);
}
@@ -628,7 +628,7 @@ impl Router {
if let Ok(workers_guard) = self.workers.read() {
if let Some(worker) = workers_guard.iter().find(|w| w.url() == worker_url) {
worker.decrement_load();
RouterMetrics::set_running_requests(&worker_url, worker.load());
RouterMetrics::set_running_requests(worker_url, worker.load());
}
}
}
@@ -659,7 +659,7 @@ impl Router {
if let Ok(workers_guard) = self.workers.read() {
if let Some(worker) = workers_guard.iter().find(|w| w.url() == worker_url) {
worker.decrement_load();
RouterMetrics::set_running_requests(&worker_url, worker.load());
RouterMetrics::set_running_requests(worker_url, worker.load());
}
}
}
@@ -688,7 +688,7 @@ impl Router {
{
if let Ok(workers_guard) = workers.read() {
if let Some(worker) =
workers_guard.iter().find(|w| w.url() == &worker_url)
workers_guard.iter().find(|w| w.url() == worker_url)
{
worker.decrement_load();
RouterMetrics::set_running_requests(
@@ -711,8 +711,7 @@ impl Router {
}
if !decremented {
if let Ok(workers_guard) = workers.read() {
if let Some(worker) = workers_guard.iter().find(|w| w.url() == &worker_url)
{
if let Some(worker) = workers_guard.iter().find(|w| w.url() == worker_url) {
worker.decrement_load();
RouterMetrics::set_running_requests(&worker_url, worker.load());
}
@@ -783,7 +782,7 @@ impl Router {
));
}
match client.get(&format!("{}/health", worker_url)).send().await {
match client.get(format!("{}/health", worker_url)).send().await {
Ok(res) => {
if res.status().is_success() {
let mut workers_guard = self.workers.write().unwrap();
@@ -953,7 +952,7 @@ impl Router {
match self
.client
.get(&format!("{}/get_load", worker_url))
.get(format!("{}/get_load", worker_url))
.send()
.await
{
@@ -1036,7 +1035,7 @@ impl Router {
worker_url
};
match client.get(&format!("{}/get_load", worker_url)).send().await {
match client.get(format!("{}/get_load", worker_url)).send().await {
Ok(res) if res.status().is_success() => match res.bytes().await {
Ok(bytes) => match serde_json::from_slice::<serde_json::Value>(&bytes) {
Ok(data) => data