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

Add try/except around extraction to accommodate failing uncompression in pyani download #385

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

baileythegreen
Copy link
Contributor

Fixes problem where failure to extract the contents of individual zip files from pyani download triggers a SystemExit.

Closes #383.

Please include a summary of the change and which issue is fixed. Please also include the motivation and context, and note the tests that apply to these changes.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • This change requires a documentation update
  • This is a documentation update

Action Checklist

  • Work on a single issue/concept (if there are multiple separate issues to address, please use a separate pull request for each)
  • Fork the pyani repository under your own account (please allow write access for repository maintainers)
  • Set up an appropriate development environment (please see CONTRIBUTING.md)
  • Create a new branch with a short, descriptive name
  • Work on this branch
    • style guidelines have been followed
    • new code is commented, especially in hard-to-understand areas
    • corresponding changes to documentation have been made
    • tests for the change have been added that demonstrate the fix or feature works
  • Test locally with pytest -v non-passing code will not be merged
  • Rebase against origin/master
  • Check changes with flake8 and black before submission
  • Commit branch
  • Submit pull request, describing the content and intent of the pull request
  • Request a code review
  • Continue the discussion at Pull requests section in the pyani repository

@codecov
Copy link

codecov bot commented Mar 14, 2022

Codecov Report

Merging #385 (48119e4) into master (62949c4) will decrease coverage by 0.07%.
The diff coverage is 58.33%.

@@            Coverage Diff             @@
##           master     #385      +/-   ##
==========================================
- Coverage   75.82%   75.74%   -0.08%     
==========================================
  Files          55       55              
  Lines        3747     3756       +9     
==========================================
+ Hits         2841     2845       +4     
- Misses        906      911       +5     

@widdowquinn widdowquinn changed the title Add try/except around extraction to prevent pyani falling over Add try/except around extraction to accommodate failing uncompression in pyani download Mar 15, 2022
Copy link
Owner

@widdowquinn widdowquinn left a comment

Choose a reason for hiding this comment

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

Looks like it should work - I've still to check locally, and I may expand the logger warning.

@baileythegreen
Copy link
Contributor Author

Even with the custom exception class, the fact that I am handling the error means pytest does not recognise it as thrown if the test is called from the top of subcmd_download. Using download.exract_genomes() as the entry point might solve it, but will require the creation of several fixtures to pass as its parameters—and those fixtures will be basically identical to the return values of the mocked functions in mock_single_genome_dl.

I believe passing fixtures into mock functions (that use the monkeypatch fixture) is not really done, or I would abstract out the objects to avoid redundancy.

Currently, I have opted to write a unit test for download.extract_contigs(), the most proximal source of the raised Exception. This is rather straightfoward, as the error is not handled there, and the only inputs are two Paths. However, it means that the actual try/except blocks are flagged by codecov.

Should I pursue tests for those blocks?

@baileythegreen
Copy link
Contributor Author

@widdowquinn Do you find the current state of testing for these changes sufficient, or would you want to see something else?

@baileythegreen baileythegreen added this to the 0.3.0 milestone May 4, 2022
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.

pyani download is blocked if downloaded file cannot be uncompressed.
2 participants