Unverified Commit e75bcf67 authored by Graham King's avatar Graham King Committed by GitHub
Browse files

fix(dynamo-run): Run without etcd/nats, HTTP port to 8000 (#4555)


Signed-off-by: default avatarGraham King <grahamk@nvidia.com>
parent f0ca16f0
...@@ -31,7 +31,7 @@ pub struct Flags { ...@@ -31,7 +31,7 @@ pub struct Flags {
/// HTTP port. `in=http` only /// HTTP port. `in=http` only
/// If tls_cert_path and tls_key_path are provided, this will be TLS/HTTPS. /// If tls_cert_path and tls_key_path are provided, this will be TLS/HTTPS.
#[arg(long, default_value = "8080")] #[arg(long, default_value = "8000")]
pub http_port: u16, pub http_port: u16,
/// TLS certificate file /// TLS certificate file
......
...@@ -77,17 +77,23 @@ pub async fn run( ...@@ -77,17 +77,23 @@ pub async fn run(
if let Input::Endpoint(path) = &in_opt { if let Input::Endpoint(path) = &in_opt {
builder.endpoint_id(Some(path.parse().with_context(|| path.clone())?)); builder.endpoint_id(Some(path.parse().with_context(|| path.clone())?));
} }
let selected_store: KeyValueStoreSelect = flags.store_kv.parse()?; let dst_config = if is_process_local(&in_opt, &out_opt) {
let request_plane: RequestPlaneMode = flags.request_plane.parse()?; // We are both the frontend and backend, no networking
let dst_config = DistributedConfig { DistributedConfig::process_local()
store_backend: selected_store, } else {
// We only need NATS here to monitor it's metrics, so only if it's our request plane. // Normal case
nats_config: if request_plane.is_nats() { let selected_store: KeyValueStoreSelect = flags.store_kv.parse()?;
Some(nats::ClientOptions::default()) let request_plane: RequestPlaneMode = flags.request_plane.parse()?;
} else { DistributedConfig {
None store_backend: selected_store,
}, // We only need NATS here to monitor it's metrics, so only if it's our request plane.
request_plane, nats_config: if request_plane.is_nats() {
Some(nats::ClientOptions::default())
} else {
None
},
request_plane,
}
}; };
let distributed_runtime = DistributedRuntime::new(runtime.clone(), dst_config).await?; let distributed_runtime = DistributedRuntime::new(runtime.clone(), dst_config).await?;
let local_model = builder.build().await?; let local_model = builder.build().await?;
...@@ -117,6 +123,18 @@ pub async fn run( ...@@ -117,6 +123,18 @@ pub async fn run(
Ok(()) Ok(())
} }
pub fn is_in_dynamic(in_opt: &Input) -> bool {
matches!(in_opt, Input::Endpoint(_))
}
pub fn is_out_dynamic(out_opt: &Option<Output>) -> bool {
matches!(out_opt, Some(Output::Auto))
}
fn is_process_local(in_opt: &Input, out_opt: &Option<Output>) -> bool {
!is_in_dynamic(in_opt) && !is_out_dynamic(out_opt)
}
/// Create the engine matching `out_opt` /// Create the engine matching `out_opt`
/// Note validation happens in Flags::validate. In here assume everything is going to work. /// Note validation happens in Flags::validate. In here assume everything is going to work.
async fn engine_for( async fn engine_for(
......
...@@ -127,17 +127,9 @@ async fn wrapper(runtime: dynamo_runtime::Runtime) -> anyhow::Result<()> { ...@@ -127,17 +127,9 @@ async fn wrapper(runtime: dynamo_runtime::Runtime) -> anyhow::Result<()> {
.chain(env::args().skip(non_flag_params)), .chain(env::args().skip(non_flag_params)),
)?; )?;
if is_in_dynamic(&in_opt) && is_out_dynamic(&out_opt) { if dynamo_run::is_in_dynamic(&in_opt) && dynamo_run::is_out_dynamic(&out_opt) {
anyhow::bail!("Cannot use endpoint for both in and out"); anyhow::bail!("Cannot use endpoint for both in and out");
} }
dynamo_run::run(runtime, in_opt, out_opt, flags).await dynamo_run::run(runtime, in_opt, out_opt, flags).await
} }
fn is_in_dynamic(in_opt: &Input) -> bool {
matches!(in_opt, Input::Endpoint(_))
}
fn is_out_dynamic(out_opt: &Option<Output>) -> bool {
matches!(out_opt, Some(Output::Auto))
}
...@@ -447,6 +447,18 @@ impl DistributedConfig { ...@@ -447,6 +447,18 @@ impl DistributedConfig {
request_plane, request_plane,
} }
} }
/// A DistributedConfig that isn't distributed, for when the frontend and backend are in the
/// same process.
pub fn process_local() -> DistributedConfig {
DistributedConfig {
store_backend: KeyValueStoreSelect::Memory,
nats_config: None,
// This won't be used in process local, so we likely need a "none" option to
// communicate that and avoid opening the ports.
request_plane: RequestPlaneMode::Tcp,
}
}
} }
/// Request plane transport mode configuration /// Request plane transport mode configuration
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment