feat(select): add metrics reporting to selection methods
Integrates an obisys::Reporter across indexing and command modules to capture execution metrics. Replaces discarded timer stops with explicit rep.push() calls, adds timing instrumentation for the pack stage, and prints collected reports after each selection branch.
This commit is contained in:
@@ -3,7 +3,7 @@ use std::io;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use obikpartitionner::{KmerPartition, OutputCol, PARTITIONS_SUBDIR};
|
use obikpartitionner::{KmerPartition, OutputCol, PARTITIONS_SUBDIR};
|
||||||
use obisys::{Stage, progress_bar};
|
use obisys::{Reporter, Stage, progress_bar};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use crate::error::{OKIError, OKIResult};
|
use crate::error::{OKIError, OKIResult};
|
||||||
@@ -25,6 +25,7 @@ impl KmerIndex {
|
|||||||
threshold: u32,
|
threshold: u32,
|
||||||
output_presence: bool,
|
output_presence: bool,
|
||||||
force: bool,
|
force: bool,
|
||||||
|
rep: &mut Reporter,
|
||||||
) -> OKIResult<Self> {
|
) -> OKIResult<Self> {
|
||||||
let output = output.as_ref();
|
let output = output.as_ref();
|
||||||
|
|
||||||
@@ -80,13 +81,14 @@ impl KmerIndex {
|
|||||||
).map_err(OKIError::Partition)?;
|
).map_err(OKIError::Partition)?;
|
||||||
|
|
||||||
pb.finish_and_clear();
|
pb.finish_and_clear();
|
||||||
|
rep.push(t.stop());
|
||||||
let _ = t.stop();
|
|
||||||
|
|
||||||
fs::File::create(output.join(SENTINEL_INDEXED))?;
|
fs::File::create(output.join(SENTINEL_INDEXED))?;
|
||||||
|
|
||||||
let idx = KmerIndex::open(output)?;
|
let idx = KmerIndex::open(output)?;
|
||||||
|
let t_pack = Stage::start("pack");
|
||||||
idx.pack_matrices()?;
|
idx.pack_matrices()?;
|
||||||
|
rep.push(t_pack.stop());
|
||||||
Ok(idx)
|
Ok(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +100,7 @@ impl KmerIndex {
|
|||||||
specs: &[OutputCol],
|
specs: &[OutputCol],
|
||||||
threshold: u32,
|
threshold: u32,
|
||||||
output_presence: bool,
|
output_presence: bool,
|
||||||
|
rep: &mut Reporter,
|
||||||
) -> OKIResult<()> {
|
) -> OKIResult<()> {
|
||||||
if self.state() != IndexState::Indexed {
|
if self.state() != IndexState::Indexed {
|
||||||
return Err(OKIError::NotIndexed(self.root_path.clone()));
|
return Err(OKIError::NotIndexed(self.root_path.clone()));
|
||||||
@@ -106,7 +109,6 @@ impl KmerIndex {
|
|||||||
let n_src_genomes = self.meta.genomes.len();
|
let n_src_genomes = self.meta.genomes.len();
|
||||||
let n_partitions = self.partition.n_partitions();
|
let n_partitions = self.partition.n_partitions();
|
||||||
|
|
||||||
// Open a second handle to the same path so we can borrow src and dst simultaneously.
|
|
||||||
let src_partition = KmerPartition::open_with_config(
|
let src_partition = KmerPartition::open_with_config(
|
||||||
&self.root_path,
|
&self.root_path,
|
||||||
self.meta.config.kmer_size,
|
self.meta.config.kmer_size,
|
||||||
@@ -132,17 +134,17 @@ impl KmerIndex {
|
|||||||
).map_err(OKIError::Partition)?;
|
).map_err(OKIError::Partition)?;
|
||||||
|
|
||||||
pb.finish_and_clear();
|
pb.finish_and_clear();
|
||||||
|
rep.push(t.stop());
|
||||||
|
|
||||||
let _ = t.stop();
|
|
||||||
|
|
||||||
// Update index.meta with new genome list and with_counts flag.
|
|
||||||
self.meta.config.with_counts = !output_presence;
|
self.meta.config.with_counts = !output_presence;
|
||||||
self.meta.genomes = specs.iter()
|
self.meta.genomes = specs.iter()
|
||||||
.map(|s| GenomeInfo::new(s.label.clone()))
|
.map(|s| GenomeInfo::new(s.label.clone()))
|
||||||
.collect();
|
.collect();
|
||||||
self.meta.write(&self.root_path)?;
|
self.meta.write(&self.root_path)?;
|
||||||
|
|
||||||
|
let t_pack = Stage::start("pack");
|
||||||
self.pack_matrices()?;
|
self.pack_matrices()?;
|
||||||
|
rep.push(t_pack.stop());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use std::path::PathBuf;
|
|||||||
use clap::{Args, ValueEnum};
|
use clap::{Args, ValueEnum};
|
||||||
use obikindex::{GenomeInfo, KmerIndex};
|
use obikindex::{GenomeInfo, KmerIndex};
|
||||||
use obikpartitionner::{AggOp, OutputCol};
|
use obikpartitionner::{AggOp, OutputCol};
|
||||||
|
use obisys::Reporter;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
use super::predicate::matching_genome_indices;
|
use super::predicate::matching_genome_indices;
|
||||||
@@ -229,20 +230,24 @@ pub fn run(args: SelectArgs) {
|
|||||||
if output_presence { "presence" } else { "count" },
|
if output_presence { "presence" } else { "count" },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let mut rep = Reporter::new();
|
||||||
|
|
||||||
if args.in_place {
|
if args.in_place {
|
||||||
src.select_in_place(&specs, args.presence_threshold, output_presence)
|
src.select_in_place(&specs, args.presence_threshold, output_presence, &mut rep)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
eprintln!("select error: {e}");
|
eprintln!("select error: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
});
|
});
|
||||||
|
rep.print();
|
||||||
info!("selected in-place → {}", args.source.display());
|
info!("selected in-place → {}", args.source.display());
|
||||||
} else {
|
} else {
|
||||||
let output = args.output.unwrap();
|
let output = args.output.unwrap();
|
||||||
KmerIndex::select(&output, &src, &specs, args.presence_threshold, output_presence, args.force)
|
KmerIndex::select(&output, &src, &specs, args.presence_threshold, output_presence, args.force, &mut rep)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
eprintln!("select error: {e}");
|
eprintln!("select error: {e}");
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
});
|
});
|
||||||
|
rep.print();
|
||||||
info!("selected index → {}", output.display());
|
info!("selected index → {}", output.display());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user