Skip to content

Commit

Permalink
feat!: provide sub command "server run" (#600) (#602)
Browse files Browse the repository at this point in the history
This moves "run-server" to "server run".

Release-As: 0.30.0
  • Loading branch information
holtgrewe authored Nov 8, 2024
1 parent 48ebdfd commit 48382b6
Show file tree
Hide file tree
Showing 16 changed files with 533 additions and 160 deletions.
124 changes: 121 additions & 3 deletions Cargo.lock

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

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "Variant effect prediction all in Rust"
license = "MIT"
repository = "https://github.com/varfish-org/mehari"
readme = "README.md"
rust-version = "1.70.0"
rust-version = "1.75.0"

[features]
default = []
Expand All @@ -33,6 +33,7 @@ async-compression = { version = "0.4", features = ["tokio", "gzip"] }
bgzip = "0.3"
bio = "2.0.3"
biocommons-bioutils = "0.1.4"
built = { version = "0.7", features = ["chrono", "semver"] }
byteorder = "1.4"
byte-unit = "5.1"
chrono = "0.4"
Expand Down Expand Up @@ -82,15 +83,19 @@ tracing-subscriber = "0.3"
tracing = { version = "0.1", features = ["log"] }
uuid = { version = "1.11", features = ["fast-rng", "serde"] }
zstd = "0.13"
utoipa = { version = "4.2.3", features = ["actix_extras", "chrono", "indexmap", "openapi_extensions", "preserve_order", "yaml"] }
utoipa-swagger-ui = { version = "7.0.1", features = ["actix-web"] }
utoipa-actix-web = "0.1.1"

[dependencies.noodles]
version = "0.77.0"
features = ["async", "bgzf", "core", "vcf", "bcf", "csi", "fasta", "tabix"]

[build-dependencies]
anyhow = "1.0"
prost-build = "0.13.3"
built = { version = "0.7", features = ["cargo-lock", "dependency-tree", "git2", "chrono", "semver"] }
pbjson-build = "0.7.0"
prost-build = "0.13.3"

[dev-dependencies]
async-std = { version = "1.13", features = ["attributes"] }
Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use std::{env, path::PathBuf};

fn main() -> Result<(), anyhow::Error> {
// Integration of `prost-build` and `pbjson-build`.
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("protos");
let proto_files = ["mehari/txs.proto", "mehari/server.proto"]
.iter()
Expand Down Expand Up @@ -32,5 +33,8 @@ fn main() -> Result<(), anyhow::Error> {
.register_descriptors(&descriptor_set)?
.build(&[".mehari"])?;

// Integration of `built`.
built::write_built_file().map_err(|e| anyhow::anyhow!("Failed to write built file: {}", e))?;

Ok(())
}
11 changes: 11 additions & 0 deletions src/annotate/seqvars/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ pub struct Provider {
picked_gene_to_tx_id: Option<Vec<GeneToTxId>>,
/// The assembly of the provider.
assembly: Assembly,
/// The data version.
data_version: String,
/// The schema version.
schema_version: String,
}

Expand Down Expand Up @@ -357,6 +359,15 @@ impl Provider {
}
}

/// Return the assembly of the provider.
///
/// # Returns
///
/// The assembly of the provider.
pub fn assembly(&self) -> Assembly {
self.assembly
}

/// Return whether transcript picking is enabled.
pub fn transcript_picking(&self) -> bool {
self.picked_gene_to_tx_id.is_some()
Expand Down
2 changes: 1 addition & 1 deletion src/common/io/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ mod test {
// Note that the 14kb.txt file contains about 14 KB of data so bgz will have multiple 4KB
// blocks.

let mut reader = super::open_read_maybe_gz(&format!("tests/common/io/{}", path))?;
let mut reader = super::open_read_maybe_gz(format!("tests/common/io/{}", path))?;
let mut buf = Vec::new();
reader.read_to_end(&mut buf)?;

Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ pub mod pbs;
pub mod ped;
pub mod server;
pub mod verify;

/// Information about the build.
pub mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
25 changes: 22 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ enum Commands {
Db(Db),
/// Annotation related commands.
Annotate(Annotate),
/// Server related commands.
Server(Server),
/// Verification related commands.
Verify(Verify),
/// Server related commands.
RunServer(server::Args),
}

/// Parsing of "db *" sub commands.
Expand Down Expand Up @@ -145,6 +145,22 @@ enum AnnotateCommands {
Strucvars(annotate::strucvars::Args),
}

/// Parsing of "server *" sub commands.
#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
struct Server {
/// The sub command to run
#[command(subcommand)]
command: ServerCommands,
}

/// Enum supporting the parsing of "server *" sub commands.
#[derive(Debug, Subcommand)]
enum ServerCommands {
Run(server::run::Args),
Schema(server::schema::Args),
}

/// Parsing of "verify *" sub commands.
#[derive(Debug, Args)]
#[command(args_conflicts_with_subcommands = true)]
Expand Down Expand Up @@ -202,10 +218,13 @@ async fn main() -> Result<(), anyhow::Error> {
annotate::strucvars::run(&cli.common, args).await?
}
},
Commands::Server(server) => match &server.command {
ServerCommands::Run(args) => server::run::run(&cli.common, args).await?,
ServerCommands::Schema(args) => server::schema::run(&cli.common, args)?,
},
Commands::Verify(verify) => match &verify.command {
VerifyCommands::Seqvars(args) => verify::seqvars::run(&cli.common, args)?,
},
Commands::RunServer(args) => server::run(&cli.common, args).await?,
}

tracing::info!("... the dromedary is back in the stable.");
Expand Down
Loading

0 comments on commit 48382b6

Please sign in to comment.