[model-gateway] add both python and rust cli alias (#13678)
This commit is contained in:
+39
-12
@@ -1,6 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use clap::{ArgAction, Parser, ValueEnum};
|
||||
use clap::{ArgAction, Parser, Subcommand, ValueEnum};
|
||||
use sglang_router_rs::{
|
||||
config::{
|
||||
CircuitBreakerConfig, ConfigError, ConfigResult, DiscoveryConfig, HealthCheckConfig,
|
||||
@@ -71,29 +71,31 @@ impl std::fmt::Display for Backend {
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(name = "sglang-router")]
|
||||
#[command(about = "SGLang Router - High-performance request distribution across worker nodes")]
|
||||
#[command(name = "sglang-router", alias = "smg", alias = "amg")]
|
||||
#[command(about = "SGLang Model Gateway - High-performance inference gateway")]
|
||||
#[command(args_conflicts_with_subcommands = true)]
|
||||
#[command(long_about = r#"
|
||||
SGLang Router - High-performance request distribution across worker nodes
|
||||
SGLang Model Gateway - Rust-based inference gateway
|
||||
|
||||
Usage:
|
||||
This launcher enables starting a router with individual worker instances. It is useful for
|
||||
multi-node setups or when you want to start workers and router separately.
|
||||
smg launch [OPTIONS] Launch router (short command)
|
||||
amg launch [OPTIONS] Launch router (alternative)
|
||||
sglang-router [OPTIONS] Launch router (full name)
|
||||
|
||||
Examples:
|
||||
# Regular mode
|
||||
sglang-router --worker-urls http://worker1:8000 http://worker2:8000
|
||||
smg launch --worker-urls http://worker1:8000 http://worker2:8000
|
||||
|
||||
# PD disaggregated mode with same policy for both
|
||||
sglang-router --pd-disaggregation \
|
||||
# PD disaggregated mode
|
||||
smg launch --pd-disaggregation \
|
||||
--prefill http://127.0.0.1:30001 9001 \
|
||||
--prefill http://127.0.0.2:30002 9002 \
|
||||
--decode http://127.0.0.3:30003 \
|
||||
--decode http://127.0.0.4:30004 \
|
||||
--policy cache_aware
|
||||
|
||||
# PD mode with different policies for prefill and decode
|
||||
sglang-router --pd-disaggregation \
|
||||
# With different policies
|
||||
smg launch --pd-disaggregation \
|
||||
--prefill http://127.0.0.1:30001 9001 \
|
||||
--prefill http://127.0.0.2:30002 \
|
||||
--decode http://127.0.0.3:30003 \
|
||||
@@ -101,6 +103,25 @@ Examples:
|
||||
--prefill-policy cache_aware --decode-policy power_of_two
|
||||
|
||||
"#)]
|
||||
struct Cli {
|
||||
#[command(subcommand)]
|
||||
command: Option<Commands>,
|
||||
|
||||
#[command(flatten)]
|
||||
router_args: CliArgs,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
enum Commands {
|
||||
/// Launch the router (same as running without subcommand)
|
||||
#[command(visible_alias = "start")]
|
||||
Launch {
|
||||
#[command(flatten)]
|
||||
args: CliArgs,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct CliArgs {
|
||||
#[arg(long, default_value = "0.0.0.0")]
|
||||
host: String,
|
||||
@@ -683,7 +704,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
}
|
||||
|
||||
let cli_args = CliArgs::parse_from(filtered_args);
|
||||
let cli = Cli::parse_from(filtered_args);
|
||||
|
||||
// Handle subcommands or use direct args
|
||||
let cli_args = match cli.command {
|
||||
Some(Commands::Launch { args }) => args,
|
||||
None => cli.router_args,
|
||||
};
|
||||
|
||||
println!("SGLang Router starting...");
|
||||
println!("Host: {}:{}", cli_args.host, cli_args.port);
|
||||
|
||||
Reference in New Issue
Block a user