Using vergen

This commit is contained in:
Nicolas Patry 2023-05-01 18:39:35 +02:00
parent 982a04246b
commit 9763ff0989
No known key found for this signature in database
GPG Key ID: 6AE76ACC68FFBAF9
7 changed files with 59 additions and 27 deletions

View File

@ -10,7 +10,8 @@ body:
The full command line used that causes issues: The full command line used that causes issues:
OS version: OS version:
Rust version (if self-compiling, `cargo version`): Rust version (if self-compiling, `cargo version`):
Model being used (If local model please explicit the kind of model and/or equivalents): Model being used (`curl 127.0.0.1:8080/info | jq`):
If local model please explicit the kind of model and/or equivalents.
Hardware used (GPUs, how many, on which cloud) (`nvidia-smi`): Hardware used (GPUs, how many, on which cloud) (`nvidia-smi`):
Deployment specificities (Kubernetes, EKS, AKS, any particular deployments): Deployment specificities (Kubernetes, EKS, AKS, any particular deployments):
The current version being used: The current version being used:

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
.idea .idea
target target
router/tokenizer.json router/tokenizer.json
launcher/src/versions.rs

41
Cargo.lock generated
View File

@ -1428,6 +1428,15 @@ dependencies = [
"minimal-lexical", "minimal-lexical",
] ]
[[package]]
name = "ntapi"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "nu-ansi-term" name = "nu-ansi-term"
version = "0.46.0" version = "0.46.0"
@ -2063,6 +2072,15 @@ dependencies = [
"walkdir", "walkdir",
] ]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.37.11" version = "0.37.11"
@ -2136,6 +2154,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "semver"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.160" version = "1.0.160"
@ -2345,6 +2369,20 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "sysinfo"
version = "0.28.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4c2f3ca6693feb29a89724516f016488e9aafc7f37264f898593ee4b942f31b"
dependencies = [
"cfg-if",
"core-foundation-sys",
"libc",
"ntapi",
"once_cell",
"winapi",
]
[[package]] [[package]]
name = "tar" name = "tar"
version = "0.4.38" version = "0.4.38"
@ -2399,6 +2437,7 @@ dependencies = [
"subprocess", "subprocess",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"vergen",
] ]
[[package]] [[package]]
@ -2985,7 +3024,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1b86a8af1dedf089b1c78338678e4c7492b6045649042d94faf19690499d236" checksum = "c1b86a8af1dedf089b1c78338678e4c7492b6045649042d94faf19690499d236"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"rustc_version",
"rustversion", "rustversion",
"sysinfo",
"time", "time",
] ]

View File

@ -17,3 +17,6 @@ tracing-subscriber = { version = "0.3.16", features = ["json"] }
[dev-dependencies] [dev-dependencies]
float_eq = "1.0.1" float_eq = "1.0.1"
reqwest = { version = "0.11.14", features = ["blocking", "json"] } reqwest = { version = "0.11.14", features = ["blocking", "json"] }
[build-dependencies]
vergen = { version = "8.0.0", features = ["build", "cargo", "git", "gitcl", "rustc", "si"] }

View File

@ -1,24 +1,12 @@
use std::fs::File; use std::error::Error;
use std::io::Write; use vergen::EmitBuilder;
use std::process::Command;
pub fn cargo_version() -> Option<String> { fn main() -> Result<(), Box<dyn Error>> {
let output = Command::new("cargo").args(&["version"]).output().ok()?; // Emit the instructions
let output = String::from_utf8(output.stdout).ok()?; EmitBuilder::builder()
Some(output.trim().to_string()) .all_cargo()
} .all_git()
.all_rustc()
fn main() { .emit()?;
let output = Command::new("git") Ok(())
.args(&["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap().trim().to_string();
let cargo_version = cargo_version().unwrap_or("N/A".to_string());
let mut file = File::create("src/versions.rs").unwrap();
file.write(format!("pub static GIT_HASH: &str = \"{git_hash}\";\n").as_bytes())
.unwrap();
file.write(format!(r#"pub static CARGO_VERSION: &str = "{cargo_version}";"#).as_bytes())
.unwrap();
} }

View File

@ -23,8 +23,9 @@ pub fn docker_image() -> Option<String> {
} }
pub fn print_env() { pub fn print_env() {
println!("Cargo version: {}", crate::versions::CARGO_VERSION); println!("Target: {}", env!("VERGEN_CARGO_TARGET_TRIPLE"));
println!("Commit SHA: {}", crate::versions::GIT_HASH); println!("Cargo version: {}", env!("VERGEN_RUSTC_SEMVER"));
println!("Commit SHA: {}", env!("VERGEN_GIT_SHA"));
println!( println!(
"Docker image sha: {}", "Docker image sha: {}",
docker_image().unwrap_or("N/A".to_string()) docker_image().unwrap_or("N/A".to_string())

View File

@ -15,7 +15,6 @@ use std::{fs, io};
use subprocess::{ExitStatus, Popen, PopenConfig, PopenError, Redirection}; use subprocess::{ExitStatus, Popen, PopenConfig, PopenError, Redirection};
mod env_cli; mod env_cli;
mod versions;
/// App Configuration /// App Configuration
#[derive(Parser, Debug)] #[derive(Parser, Debug)]