scverse / anndata

Annotated data.
http://anndata.readthedocs.io
BSD 3-Clause "New" or "Revised" License
579 stars 154 forks source link

anndata optional dependency import system can behave poorly with autodoc_mock_imports #1134

Open Intron7 opened 1 year ago

Intron7 commented 1 year ago

Please make sure these conditions are met

Report

I ran into a problem with the new GPU dependencies and how they are loaded in anndata. For the rapids-singlecell docs I mock import all gpu packages, this includes cupy and cupyx. Because of the mock imports anndata thought it was in a GPU enviroment and tried to load the packages. The docs creation froze and didn't finish. Mock importing anndata didn't fix the issue it just resulted in a bug. What I had to do in the end is importing anndata at the start of the conf.py so that it doesn't know about cupy. If there is a more elegant solution than this please let me know.

Versions

anndata 0.10.0rc1

ivirshup commented 1 year ago

Hmm, I'm not 100% sure if I'd consider this a bug in anndata just yet, since this is definitely a strange use case.

Could you share how you did the mocking? And is this something that cupy recommends people do?

Intron7 commented 1 year ago

I agree that it's not necessarily a bug. The behaviour is nevertheless unwanted and doesn't throw any meaningful errors.

autodoc_mock_imports = ["cudf", "cuml", "cugraph", "cupy", "cupyx"]

This is how I mocked the gpu imports.

flying-sheep commented 11 months ago

Where is the code that checks if anndata is in a CUDA environment? I feel like it should be easy to change it so it doesn’t try to use it if it’s mocked.

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. Please add a comment if you want to keep the issue open. Thank you for your contributions!