Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions quasi-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ nalgebra = "0.33"
# CLI
clap = { version = "4", features = ["derive"] }

# HTTP server
axum = "0.8"
tokio = { version = "1", features = ["full"] }

# Error handling
anyhow = "1"
thiserror = "2"
Expand Down
1 change: 1 addition & 0 deletions quasi-bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ pub mod partition;
pub mod pipeline;
pub mod postprocess;
pub mod rhf;
pub mod server;
20 changes: 20 additions & 0 deletions quasi-bridge/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! ```text
//! quasi-bridge run --smiles "O" --basis sto-3g --accuracy chemical
//! quasi-bridge analyze --smiles "[H][H]"
//! quasi-bridge serve --bind 0.0.0.0:9090
//! ```

use clap::{Parser, Subcommand};
Expand Down Expand Up @@ -44,6 +45,12 @@ enum Command {
#[arg(long, default_value = "sto-3g")]
basis: String,
},
/// Start HTTP server
Serve {
/// Bind address (e.g. 0.0.0.0:9090)
#[arg(long, default_value = "127.0.0.1:9090")]
bind: String,
},
}

fn main() {
Expand Down Expand Up @@ -104,6 +111,19 @@ fn main() {
}
}
}
Command::Serve { bind } => {
let rt = tokio::runtime::Runtime::new().expect("failed to create tokio runtime");
rt.block_on(async {
let app = quasi_bridge::server::app();
let listener = tokio::net::TcpListener::bind(&bind)
.await
.unwrap_or_else(|e| panic!("failed to bind {bind}: {e}"));
eprintln!("quasi-bridge serving on http://{bind}");
axum::serve(listener, app)
.await
.expect("server error");
});
}
Command::Analyze { smiles, basis } => {
// Just RHF + partition analysis
let atoms = match quasi_bridge::molecule::from_smiles(&smiles) {
Expand Down
Loading
Loading