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

Load .mrc using Distributed and with Direct Electron Metadata #162

Merged
merged 18 commits into from Nov 29, 2023

Conversation

CSSFrancis
Copy link
Member

@CSSFrancis CSSFrancis commented Sep 25, 2023

Description of the change

This adds support for loading .mrc files using the dask-distributed backend and memory mapping. This is helpful for loading large files using multiple threads split across many machines.

The methods in the _distributed file should be fairly extendable and can be applied to other binary files which use the np.memmap function.

Changes:

  • Added memmap_distributed function
  • Add load metadata.txt file from DirectElectron
  • Added distributed and chunks kwargs to the .mrc file loader

Progress of the PR

  • Change implemented (can be split into several points),
    • Add memmap_distributed function
    • Add load metadata.txt file from DirectElectron
  • add tests
    • Test loading using distributed option
    • Test using metadata.txt file (Need to make small test files with different sizes)
  • update docstring (if appropriate),
  • update user guide (if appropriate),
  • add a changelog entry in the upcoming_changes folder (see upcoming_changes/README.rst),
  • Check formatting of the changelog entry (and eventual user guide changes) in the docs/readthedocs.org:rosettasciio build of this PR (link in github checks)
  • ready for review.

Minimal example of the bug fix or the new feature

from rsciio.mrc import file_reader
file_reader("your_mrc_file.msa", 
                    distributed=True,  # can use `dask-distributed` if wanted 
                    lazy=True, # If lazy= False will still use distributed loading but then compute
                    metadata_file = "de_metadata.txt",  # Direct Electron saved  metadata file 
                    )

rsciio/tests/test_mrc.py Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (13507d4) 86.02% compared to head (5a7eb28) 86.12%.

Files Patch % Lines
rsciio/mrc/_api.py 98.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
+ Coverage   86.02%   86.12%   +0.10%     
==========================================
  Files          81       82       +1     
  Lines       10387    10471      +84     
  Branches     2253     2274      +21     
==========================================
+ Hits         8935     9018      +83     
  Misses        931      931              
- Partials      521      522       +1     

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

@CSSFrancis CSSFrancis mentioned this pull request Oct 16, 2023
8 tasks
@CSSFrancis CSSFrancis force-pushed the load_mrc_direct_electron branch 2 times, most recently from c379dc4 to dc6e0db Compare November 13, 2023 17:44
@CSSFrancis
Copy link
Member Author

pre-commit.ci autofix

@CSSFrancis CSSFrancis force-pushed the load_mrc_direct_electron branch 3 times, most recently from ed69998 to bde771a Compare November 28, 2023 13:40
@CSSFrancis
Copy link
Member Author

@ericpre so it seems like the Packaging CI seems to fail when adding a new file. Is that correct? It seems like it is trying to pull the file from the registered list to package (and then subsequently prune). Is this something worth trying to fix? Or just wait until the file is merged into main.

@ericpre
Copy link
Member

ericpre commented Nov 28, 2023

Yes, the packaging failure is normal, it will pass once the PR is merged.

@CSSFrancis CSSFrancis marked this pull request as ready for review November 28, 2023 17:32
rsciio/utils/distributed.py Outdated Show resolved Hide resolved
rsciio/utils/distributed.py Show resolved Hide resolved
rsciio/utils/distributed.py Outdated Show resolved Hide resolved
rsciio/utils/distributed.py Show resolved Hide resolved
rsciio/utils/distributed.py Show resolved Hide resolved
rsciio/utils/distributed.py Outdated Show resolved Hide resolved
rsciio/utils/distributed.py Outdated Show resolved Hide resolved
rsciio/utils/distributed.py Show resolved Hide resolved
rsciio/utils/distributed.py Outdated Show resolved Hide resolved
rsciio/mrc/_api.py Outdated Show resolved Hide resolved
@ericpre ericpre merged commit b2dae8b into hyperspy:main Nov 29, 2023
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants