Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: provide sub command "server run" (#600) #602

Merged
merged 1 commit into from
Nov 8, 2024
Merged
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
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 @@
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 @@
}
}

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

Check warning on line 369 in src/annotate/seqvars/provider.rs

View check run for this annotation

Codecov / codecov/patch

src/annotate/seqvars/provider.rs#L367-L369

Added lines #L367 - L369 were not covered by tests

/// 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 @@
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 @@
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 @@
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)?,
},

Check warning on line 224 in src/main.rs

View check run for this annotation

Codecov / codecov/patch

src/main.rs#L221-L224

Added lines #L221 - L224 were not covered by tests
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
Loading