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: panic when FSStorage::load_sig encounters more than one Signature in a JSON record #3333

Merged
merged 51 commits into from
Nov 4, 2024

Conversation

ctb
Copy link
Contributor

@ctb ctb commented Sep 17, 2024

This PR was originally about debugging sourmash-bio/sourmash_plugin_branchwater#445, but that's going to require more work to fix properly. For now, I would like to nominate it for merge because sourmash fails silently in this situation, and that's Bad.

In brief, the main thing this PR does is panic with an unimplemented! when FSStorage::load_sig encounters more than one Signature in a JSON record.

This PR also adds a bit of documentation to InnerStorage, per the bottom of this comment.


The problem at hand: when loading a SigStore/Signature from a Storage, sourmash only loads the first one and ignores any others.

fn load_sig(&self, path: &str) -> Result<SigStore> {
let raw = self.load(path)?;
let sig = Signature::from_reader(&mut &raw[..])?
// TODO: select the right sig?
.swap_remove(0);

This results from the concept of a Signature as containing one or more sketches; the history of this is described here, and it leads to some interesting silliness in the Python layer.

The contrapositive is that, in Rust, a single Signature can include multiple sketches, e.g. with different ksizes. So this works fine for the wort case where we have a single .sig file with k=21, k=31, k51.

Note that the Python layer (and hence the entire sourmash CLI) fully supports multiple Signatures in JSON: this is well tested and well covered behavior. The branchwater plugin runs into it because it is using the Rust layer and the API is not fully fleshed out there.


@ctb ctb changed the title EXP: debug multisigfile loading WIP: explicitly note that loading more than one Signature from a .sig file is unimplemented currently Oct 27, 2024
@ctb ctb changed the title WIP: explicitly note that loading more than one Signature from a .sig file is unimplemented currently WIP: panic when FSStorage::load_sig encounters more than one Signature in a JSON record Oct 27, 2024
@ctb ctb added the rust label Oct 27, 2024
@ctb
Copy link
Contributor Author

ctb commented Oct 27, 2024

@luizirber @bluegenes thoughts welcome!

@ctb ctb changed the title WIP: panic when FSStorage::load_sig encounters more than one Signature in a JSON record MRG: panic when FSStorage::load_sig encounters more than one Signature in a JSON record Oct 27, 2024
@ctb
Copy link
Contributor Author

ctb commented Nov 1, 2024

@luizirber bump!

Copy link
Contributor

@bluegenes bluegenes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good plan to me. @luizirber, did you have any thoughts?

@ctb
Copy link
Contributor Author

ctb commented Nov 4, 2024

🙏

@ctb ctb merged commit c9fb078 into latest Nov 4, 2024
42 of 44 checks passed
@ctb ctb deleted the debug_multisigfile branch November 4, 2024 16:57
ctb added a commit that referenced this pull request Nov 5, 2024
## [0.17.0] - 2024-11-05

Changes/additions:
* standardize on u32 for scaled, and introduce `ScaledType` (#3364)
* panic when `FSStorage::load_sig` encounters more than one `Signature`
in a JSON record (#3333)

Updates:

* Bump needletail from 0.5.1 to 0.6.0 (#3376)
* Bump histogram from 0.11.0 to 0.11.1 (#3377)
* Bump serde from 1.0.210 to 1.0.214 (#3368)
* Bump serde_json from 1.0.128 to 1.0.132 (#3358)
* Fix clippy lints from 1.83 beta (#3357)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants