Skip to content
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
16 changes: 8 additions & 8 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ members = [
]

[workspace.package]
version = "0.24.0"
version = "0.25.0"
edition = "2024"
authors = ["Sebastian Paez"]
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "timsseek-workspace"
version = "0.24.0"
version = "0.25.0"
requires-python = ">=3.11,<3.13"
dependencies = [
"jupyter[python]>=1.1.1",
Expand Down Expand Up @@ -55,7 +55,7 @@ packages = [
]

[tool.bumpver]
current_version = "0.24.0"
current_version = "0.25.0"
version_pattern = "MAJOR.MINOR.PATCH[-PYTAGNUM]"
tag_message = "v{new_version}"
commit_message = "chore: bump version to {new_version}"
Expand Down
2 changes: 1 addition & 1 deletion python/speclib_builder/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "speclib_builder"
version = "0.24.0"
version = "0.25.0"
requires-python = ">=3.11,<3.13"
dependencies = [
"rich",
Expand Down
2 changes: 1 addition & 1 deletion python/timsseek_rescore/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "timsseek_rescore"
version = "0.24.0"
version = "0.25.0"
requires-python = ">=3.11,<3.13"
dependencies = [
"polars",
Expand Down
2 changes: 1 addition & 1 deletion python/timsseek_rts_receiver/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "timsseek_rts_receiver"
version = "0.24.0"
version = "0.25.0"
requires-python = ">=3.11,<3.13"
description = "Add your description here"
dependencies = [
Expand Down
8 changes: 8 additions & 0 deletions rust/timsquery_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
/// Increase logging verbosity (can be repeated: -v for debug, -vv for trace)
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
pub verbose: u8,

/// Decrease logging verbosity (can be repeated: -q for warn, -qq for error)
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
pub quiet: u8,

#[command(subcommand)]
pub command: Option<Commands>,
}
Expand Down
29 changes: 27 additions & 2 deletions rust/timsquery_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,39 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

/// Converts verbosity flags to a log level string.
/// Returns the log level based on verbose/quiet counts.
/// If RUST_LOG is set, it takes precedence.
fn get_log_level(verbose: u8, quiet: u8) -> String {
// RUST_LOG environment variable takes precedence
if std::env::var("RUST_LOG").is_ok() {
return std::env::var("RUST_LOG").unwrap();
}

// Calculate effective verbosity: positive = more verbose, negative = more quiet
let effective = verbose as i8 - quiet as i8;

match effective {
2.. => "trace".to_string(),
1 => "debug".to_string(),
0 => "info".to_string(),
-1 => "warn".to_string(),
_ => "error".to_string(),
}
}

fn main() -> Result<(), CliError> {
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
let args = Args::parse();

let log_level = get_log_level(args.verbose, args.quiet);
let env_filter = EnvFilter::builder()
.with_default_directive(log_level.parse().unwrap())
.from_env_lossy();
let subscriber = Registry::default()
.with(env_filter)
.with(tracing_subscriber::fmt::layer().with_span_events(FmtSpan::CLOSE));

set_global_default(subscriber).expect("Setting default subscriber failed");
let args = Args::parse();

match args.command {
Some(Commands::QueryIndex(args)) => main_query_index(args)?,
Expand Down
8 changes: 8 additions & 0 deletions rust/timsquery_viewer/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
/// Increase logging verbosity (can be repeated: -v for debug, -vv for trace)
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
pub verbose: u8,

/// Decrease logging verbosity (can be repeated: -q for warn, -qq for error)
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
pub quiet: u8,

#[arg(
long,
value_name = "FILE",
Expand Down
37 changes: 29 additions & 8 deletions rust/timsquery_viewer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,55 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

fn setup_logger() {
let app_level = std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_string());
let env_filter = match EnvFilter::builder().parse(&app_level) {
/// Converts verbosity flags to a log level string.
/// Returns the log level based on verbose/quiet counts.
/// If RUST_LOG is set, it takes precedence.
fn get_log_level(verbose: u8, quiet: u8) -> String {
// RUST_LOG environment variable takes precedence
if std::env::var("RUST_LOG").is_ok() {
return std::env::var("RUST_LOG").unwrap();
}

// Calculate effective verbosity: positive = more verbose, negative = more quiet
let effective = verbose as i8 - quiet as i8;

match effective {
2.. => "trace".to_string(),
1 => "debug".to_string(),
0 => "info".to_string(),
-1 => "warn".to_string(),
_ => "error".to_string(),
}
}

fn setup_logger(verbose: u8, quiet: u8) {
let log_level = get_log_level(verbose, quiet);
let env_filter = match EnvFilter::builder().parse(&log_level) {
Ok(filter) => filter,
Err(_) => {
let mut warning_msg = String::new();
let _ = writeln!(
&mut warning_msg,
"Warning: Invalid RUST_LOG value: {}. Falling back to 'info'.",
app_level
"Warning: Invalid log level: {}. Falling back to 'info'.",
log_level
);
eprintln!("{}", warning_msg);
EnvFilter::new("info")
}
};

// 5. Initialize Subscriber
// Initialize Subscriber
let subscriber = Registry::default()
.with(env_filter)
.with(tracing_subscriber::fmt::layer().with_span_events(FmtSpan::CLOSE));

subscriber.init(); // simpler than set_global_default + expect
subscriber.init();
}

fn main() -> eframe::Result {
let args = cli::Cli::parse();

setup_logger();
setup_logger(args.verbose, args.quiet);
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([1400.0, 800.0])
Expand Down
8 changes: 8 additions & 0 deletions rust/timsseek_cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ use timsseek::DecoyStrategy;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
/// Increase logging verbosity (can be repeated: -v for debug, -vv for trace)
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
pub verbose: u8,

/// Decrease logging verbosity (can be repeated: -q for warn, -qq for error)
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
pub quiet: u8,

/// Path to the JSON configuration file (optional, uses defaults if not provided)
#[arg(short, long)]
pub config: Option<PathBuf>,
Expand Down
31 changes: 26 additions & 5 deletions rust/timsseek_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,34 @@ fn process_single_file(
Ok(())
}

/// Converts verbosity flags to a log level string.
/// Returns the log level based on verbose/quiet counts.
/// If RUST_LOG is set, it takes precedence.
fn get_log_level(verbose: u8, quiet: u8) -> String {
// RUST_LOG environment variable takes precedence
if std::env::var("RUST_LOG").is_ok() {
return std::env::var("RUST_LOG").unwrap();
}

// Calculate effective verbosity: positive = more verbose, negative = more quiet
let effective = verbose as i8 - quiet as i8;

match effective {
2.. => "trace".to_string(),
1 => "debug".to_string(),
0 => "info".to_string(),
-1 => "warn".to_string(),
_ => "error".to_string(),
}
}

fn main() -> std::result::Result<(), errors::CliError> {
// Parse command line arguments first to get verbosity flags
let args = Cli::parse();

let log_level = get_log_level(args.verbose, args.quiet);
let fmt_filter = EnvFilter::builder()
.with_default_directive("info".parse().unwrap())
.with_env_var("RUST_LOG")
.with_default_directive(log_level.parse().unwrap())
.from_env_lossy();

#[cfg(feature = "instrumentation")]
Expand Down Expand Up @@ -356,9 +380,6 @@ fn main() -> std::result::Result<(), errors::CliError> {

reg.init();

// Parse command line arguments
let args = Cli::parse();

// Load and parse configuration, or use defaults
let mut config = match args.config {
Some(ref config_path) => {
Expand Down
53 changes: 45 additions & 8 deletions rust/timsseek_cli/src/sample_speclib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ use clap::{
};
// use serde_json::to_string_pretty;
use timsseek::Speclib;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::prelude::*;
use tracing_subscriber::registry::Registry;

#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Cli {
/// Increase logging verbosity (can be repeated: -v for debug, -vv for trace)
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
verbose: u8,

/// Decrease logging verbosity (can be repeated: -q for warn, -qq for error)
#[arg(short, long, action = clap::ArgAction::Count, global = true)]
quiet: u8,

#[command(subcommand)]
command: SubCommands,
}
Expand Down Expand Up @@ -41,19 +53,44 @@ fn parse_speclib(speclib_file: &str) -> Result<(), timsseek::errors::LibraryRead
Ok(())
}

/// Converts verbosity flags to a log level string.
/// Returns the log level based on verbose/quiet counts.
/// If RUST_LOG is set, it takes precedence.
fn get_log_level(verbose: u8, quiet: u8) -> String {
// RUST_LOG environment variable takes precedence
if std::env::var("RUST_LOG").is_ok() {
return std::env::var("RUST_LOG").unwrap();
}

// Calculate effective verbosity: positive = more verbose, negative = more quiet
let effective = verbose as i8 - quiet as i8;

match effective {
2.. => "trace".to_string(),
1 => "debug".to_string(),
0 => "info".to_string(),
-1 => "warn".to_string(),
_ => "error".to_string(),
}
}

fn setup_logger(verbose: u8, quiet: u8) {
let log_level = get_log_level(verbose, quiet);
let env_filter = EnvFilter::builder()
.with_default_directive(log_level.parse().unwrap())
.from_env_lossy();
let subscriber = Registry::default()
.with(env_filter)
.with(tracing_subscriber::fmt::layer().with_span_events(FmtSpan::CLOSE));
subscriber.init();
}

fn main() -> Result<(), timsseek::errors::LibraryReadingError> {
// This is a placeholder for the main function.
// The actual implementation would depend on the specific requirements of the application.
let cli = Cli::parse();
setup_logger(cli.verbose, cli.quiet);

match &cli.command {
// SubCommands::Sample => {
// // Generate a sample speclib
// generate_sample_speclib();
// Ok(())
// }
SubCommands::Parse { speclib_file } => {
// Parse the provided speclib file
parse_speclib(speclib_file)?;
Ok(())
}
Expand Down
Loading