Skip to content

Commit

Permalink
Merge branch 'main' into update_docs2
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb authored Feb 18, 2024
2 parents 881e0b1 + 7b404a3 commit 0c6a3aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/python/tests/test_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ def test_simple_with_manifest_loading(runtmp):
sig63 = get_test_data('63.fa.sig.gz')

make_file_list(against_list, [sig2, sig47, sig63])
query_manifest = get_test_data("query-manifest.csv")
against_manifest = get_test_data("against-manifest.csv")
query_manifest = runtmp.output("query-manifest.csv")
against_manifest = runtmp.output("against-manifest.csv")

runtmp.sourmash("sig", "manifest", query, "-o", query_manifest)
runtmp.sourmash("sig", "manifest", against_list, "-o", against_manifest)
Expand Down
45 changes: 27 additions & 18 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,25 +364,32 @@ fn collection_from_pathlist(
})?;
let reader = BufReader::new(file);

let mut n_failed = 0;
let records: Vec<Record> = reader
// load list of paths
let lines: Vec<_> = reader
.lines()
.filter_map(|line| {
let path = line.ok()?;
match Signature::from_path(&path) {
Ok(signatures) => {
let recs: Vec<Record> = signatures
.into_iter()
.flat_map(|v| Record::from_sig(&v, &path))
.collect();
Some(recs)
}
Err(err) => {
eprintln!("Sketch loading error: {}", err);
eprintln!("WARNING: could not load sketches from path '{}'", path);
n_failed += 1;
None
}
.filter_map(|line| match line {
Ok(path) => Some(path),
Err(_err) => None,
})
.collect();

// load sketches from paths in parallel.
let n_failed = AtomicUsize::new(0);
let records: Vec<Record> = lines
.par_iter()
.filter_map(|path| match Signature::from_path(&path) {
Ok(signatures) => {
let recs: Vec<Record> = signatures
.into_iter()
.flat_map(|v| Record::from_sig(&v, &path))
.collect();
Some(recs)
}
Err(err) => {
eprintln!("Sketch loading error: {}", err);
eprintln!("WARNING: could not load sketches from path '{}'", path);
let _ = n_failed.fetch_add(1, atomic::Ordering::SeqCst);
None
}
})
.flatten()
Expand All @@ -405,6 +412,8 @@ fn collection_from_pathlist(
.build(),
),
);
let n_failed = n_failed.load(atomic::Ordering::SeqCst);

Ok((collection, n_failed))
}

Expand Down

0 comments on commit 0c6a3aa

Please sign in to comment.