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: transition internal signature loading functions #3161

Merged
merged 16 commits into from
Jun 4, 2024
Merged

Conversation

ctb
Copy link
Contributor

@ctb ctb commented May 13, 2024

Note: PR into #3153

Tackles some signature loading and saving cleanup throughout the codebase. Most changes are in the tests, and this is a significant cleanup of the test code!

Fixes #1062.


Goals:

  • deprecate external use of sourmash.signature load/save functions, because they are JSON-specific and inflexible.
  • simplify and standardize signature load/save function usage during tests;
  • get rid of deprecation messages during tests;

In brief,

  • rename sourmash.signature.load_signatures to load_signatures_from_json;
  • rename sourmash.signature.load_one_signature to load_one_signature_from_json;
  • rename sourmash.signature.save_signatures to save_signatures_to_json;
  • deprecate sourmash.save_signatures and sourmash.load_one_signature for 5.0 (joining load_signatures, which was already deprecated);
  • reduce/eliminate deprecations by transitioning internal test code to use these three functions directly from sourmash.signature instead of from the top-level sourmash import.
  • bonus: eliminate zipfile UserWarning around overwriting files, which causes lots of warnings when running tests.

Done:

  • in sourmash.signature submodule, rename load_signatures to load_signatures_from_json, load_one_signature to load_one_signatures_from_json, and save_signatures to save_signatures_to_json; make tests pass.
  • deprecate sourmash.load_one_signature and sourmash.save_signatures.
  • catch zipfile UserWarning for duplicate filenames in ZipStorage.save

TODO:

  • transition internal sourmash code+tests away from deprecated functions
  • create issue around changing API documentation prior to 5.0;

@ctb ctb changed the base branch from latest to upgrade_sig_cmds May 13, 2024 22:52
Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 92.68293% with 3 lines in your changes missing coverage. Please review.

Project coverage is 86.66%. Comparing base (2542c69) to head (922bfc2).

Files Patch % Lines
src/sourmash/sbt_storage.py 85.71% 1 Missing and 1 partial ⚠️
src/sourmash/__init__.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           latest    #3161   +/-   ##
=======================================
  Coverage   86.66%   86.66%           
=======================================
  Files         136      136           
  Lines       15821    15830    +9     
  Branches     2713     2716    +3     
=======================================
+ Hits        13711    13719    +8     
- Misses       1800     1801    +1     
  Partials      310      310           
Flag Coverage Δ
hypothesis-py 25.35% <56.09%> (+0.05%) ⬆️
python 92.33% <92.68%> (+<0.01%) ⬆️
rust 62.05% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ctb ctb changed the title WIP: transition internal signature loading functions MRG: transition internal signature loading functions May 14, 2024
@ctb
Copy link
Contributor Author

ctb commented May 14, 2024

This feels done! It changes a lot of code in dumb ways, and cleans up the warnings emitted by the test, too; probably shouldn't be combined with any more changes 😅

Ready for review, @sourmash-bio/devs

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.

lgtm

Base automatically changed from upgrade_sig_cmds to latest June 4, 2024 18:03
@ctb ctb merged commit 9283dc4 into latest Jun 4, 2024
39 of 40 checks passed
@ctb ctb deleted the rename_sig_json_fns branch June 4, 2024 18:26
ctb added a commit that referenced this pull request Jun 4, 2024
**Note:** PR into #3161 

This PR cleans up and regularizes naming output on `sig` subcommands.
Specifically, it:

- [x] adds `--set-name` to `sig intersect` and `sig subtract` to set
names on output signatures.
- [x] confirms and tests default names for output from `sig inflate`,
`sig filter`, `sig downsample`, and `sig flatten`
- [x] updates documentation appropriately
- [x] aliases `--name` to `--set-name` on `sig merge`, and nominates
`--name` for deprecation and removal on v5
- [x] nominates `--name` on `sig extract`, `sig filter`, and `sig
flatten` for deprecation and removal on v5
- [x] highlights `--name` on `sketch dna`, `sketch protein`, and `sketch
translate` - ref #3152

Fixes #1801
Fixes #3152

Related issues:
* #3173

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make load_one_signature use load_file_as_signatures API
2 participants