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

MRG: fail-exit when 0 signatures are loaded from a collection #282

Merged
merged 3 commits into from
Mar 20, 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
7 changes: 0 additions & 7 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ pub fn index<P: AsRef<Path>>(
allow_failed_sigpaths,
)?;

if collection.len() == 0 {
bail!(
"No sketches matching parameters, check input: '{}'",
&siglist
)
}

RevIndex::create(
output.as_ref(),
collection.select(selection)?.try_into()?,
Expand Down
3 changes: 2 additions & 1 deletion src/python/tests/test_multigather.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ def test_empty_against(runtmp, capfd):
against_list = runtmp.output('against.txt')
make_file_list(against_list, [])

runtmp.sourmash('scripts', 'fastmultigather', query_list, against_list,
with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash('scripts', 'fastmultigather', query_list, against_list,
'-s', '100000')

captured = capfd.readouterr()
Expand Down
5 changes: 3 additions & 2 deletions src/python/tests/test_multisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def test_bad_against(runtmp, capfd):


def test_empty_query(runtmp, capfd):
# test with an empty query list - fail gracefully
# test with an empty query list - fail with error
query_list = runtmp.output('query.txt')
against_list = runtmp.output('against.txt')

Expand All @@ -434,7 +434,8 @@ def test_empty_query(runtmp, capfd):

output = runtmp.output('out.csv')

runtmp.sourmash('scripts', 'multisearch', query_list, against_list,
with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash('scripts', 'multisearch', query_list, against_list,
'-o', output)

print(runtmp.last_result.err)
Expand Down
6 changes: 4 additions & 2 deletions src/python/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def test_nomatch_against(runtmp, capfd):

output = runtmp.output('out.csv')

runtmp.sourmash('scripts', 'manysearch', query_list, against_list,
with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash('scripts', 'manysearch', query_list, against_list,
'-o', output)

captured = capfd.readouterr()
Expand Down Expand Up @@ -470,7 +471,8 @@ def test_empty_query(runtmp, indexed, capfd):

output = runtmp.output('out.csv')

runtmp.sourmash('scripts', 'manysearch', query_list, against_list,
with pytest.raises(utils.SourmashCommandFailed):
runtmp.sourmash('scripts', 'manysearch', query_list, against_list,
'-o', output)

print(runtmp.last_result.err)
Expand Down
3 changes: 1 addition & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,7 @@ pub fn report_on_collection_loading(

// Validate sketches
if collection.is_empty() {
eprintln!("No {} signatures loaded, exiting.", report_type);
return Ok(());
bail!("No {} signatures loaded, exiting.", report_type);
}
eprintln!("Loaded {} {} signature(s)", collection.len(), report_type);
Ok(())
Expand Down
Loading