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

(feat): io submodule #1682

Merged
merged 48 commits into from
Sep 24, 2024
Merged

(feat): io submodule #1682

merged 48 commits into from
Sep 24, 2024

Conversation

ilan-gold
Copy link
Contributor

@ilan-gold ilan-gold commented Sep 20, 2024

A brief summary of how this was handled and why:

  1. I moved everything into io related to i/o
  2. I left read_zarr and read_h5ad at the top-level for now, although I think that should be deprecated in favor of everything going through io in the future despite their "high" status above the others. They are now documented as being from io to begin to encourage that behavior although we aren't throwing warnings for e.g., anndata.read_h5ad yet
  3. I also made a backwards compat for people who use from anndata._io import blah since uhhhhhhh yikes by leaving that module alone. However, at least if anyone tries to import from the top-level from anndata._io import read_h5ad, it will warn. Also, I added a public note about this issue since it seems pervasive.
  4. I added tests for the deprecations. For now, we need to check the scanpy imports for warnings but we can open the PR for scanpy before its release to adapt. I think the imports are cached or something so pytest.warns can't run reliably every time because the warning doesn't come every time....not sure what's up with that

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@ilan-gold ilan-gold added skip-gpu-ci topic: io breaking change ‼️ A breaking change that needs a major version update labels Sep 20, 2024
@ilan-gold ilan-gold added this to the 0.11.0 milestone Sep 20, 2024
tests/test_readwrite.py Outdated Show resolved Hide resolved
src/anndata/_core/anndata.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.50%. Comparing base (6d8f7ce) to head (fa9ce5e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1682      +/-   ##
==========================================
- Coverage   86.87%   84.50%   -2.38%     
==========================================
  Files          39       40       +1     
  Lines        6036     6047      +11     
==========================================
- Hits         5244     5110     -134     
- Misses        792      937     +145     
Flag Coverage Δ
84.50% <100.00%> (+0.09%) ⬆️

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

Files with missing lines Coverage Δ
src/anndata/__init__.py 93.54% <100.00%> (+0.95%) ⬆️
src/anndata/_core/anndata.py 83.72% <100.00%> (ø)
src/anndata/_core/sparse_dataset.py 92.43% <ø> (ø)
src/anndata/_io/__init__.py 100.00% <100.00%> (ø)
src/anndata/_io/read.py 82.60% <ø> (+1.55%) ⬆️
src/anndata/_io/specs/lazy_methods.py 100.00% <ø> (ø)
src/anndata/_types.py 85.29% <ø> (ø)
src/anndata/experimental/__init__.py 100.00% <100.00%> (ø)
src/anndata/io.py 100.00% <100.00%> (ø)
src/anndata/typing.py 100.00% <100.00%> (ø)
... and 1 more

... and 7 files with indirect coverage changes

Copy link
Member

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

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

Looks great! Two questions

Comment on lines 29 to 30
# We use this in test by attribute access
from . import specs # noqa: F401, E402
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why we shouldn’t just stop doing that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would need to investigate what it's doing there or what that comment even means. Maybe an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I deleted it and nothing happened so....

Copy link
Member

@flying-sheep flying-sheep Sep 20, 2024

Choose a reason for hiding this comment

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

I put that import and comment there because Isaac made the tests access this by attribute:

import anndata as ad

do_stuff_with(ad._io.specs.foobar)

instead of importing that submodule. It happened to work because some other code somewhere else caused anndata._io.specs to be imported, but “happens to work because of side effects” is not what I want to build upon.

Now that the tests no longer access stuff that way, this import is no longer necessary.

src/anndata/io/__init__.py Outdated Show resolved Hide resolved
@flying-sheep
Copy link
Member

flying-sheep commented Sep 20, 2024

I got rid of a few more obsolete import hacks: a947d3e

Why breaking change ‼️ A breaking change that needs a major version update ?

@ilan-gold
Copy link
Contributor Author

Why breaking change ‼️ ?

Hmm I guess I was just thinking "begins process for breaking change" but yea, it's not.

@ilan-gold ilan-gold removed the breaking change ‼️ A breaking change that needs a major version update label Sep 23, 2024
@ilan-gold
Copy link
Contributor Author

I got rid of a few more obsolete import hacks: a947d3e

I don't think they were so obsolete: https://dev.azure.com/scverse/anndata/_build/results?buildId=8163&view=logs&j=60c6783d-556f-53a9-3d94-3b9ccc51ad8d&t=3522b173-13e1-56b6-93d8-ed20bad6f9bb&l=60! I cleaned it up a bit to be more uniform.

@flying-sheep
Copy link
Member

flying-sheep commented Sep 23, 2024

Ah weird, I’m sure I ran the tests without zarr locally, but looking at the code I guess I probably didn’t.

I don’t like this:

image

edit: fixed in 2afc94a

docs/release-notes/0.10.2.md Outdated Show resolved Hide resolved
src/anndata/io.py Outdated Show resolved Hide resolved
@ilan-gold ilan-gold merged commit b930f27 into main Sep 24, 2024
15 checks passed
@ilan-gold ilan-gold deleted the ig/io_module branch September 24, 2024 09:39
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.

io submodule
3 participants