Skip to content

Conversation

@quentinblampey
Copy link
Contributor

If torch is installed, importing spatialdata will also import torch because of ImageTilesDataset.

This PR aims to speed up the import by making the import of torch lazy.

It's a little bit tricky to keep all the dosctrings + auto-completion. For now, it seems the auto-completion is working fine for the instances, but not the __init__ docstrings.

If you think this PR seems interesting, I can work on fixing the docstrings, else we can just close it

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.12%. Comparing base (53b9438) to head (557f53b).

Files with missing lines Patch % Lines
src/spatialdata/dataloader/__init__.py 83.33% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1027   +/-   ##
=======================================
  Coverage   92.11%   92.12%           
=======================================
  Files          49       49           
  Lines        7537     7545    +8     
=======================================
+ Hits         6943     6951    +8     
  Misses        594      594           
Files with missing lines Coverage Δ
src/spatialdata/dataloader/__init__.py 83.33% <83.33%> (+33.33%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Zethson
Copy link
Member

Zethson commented Dec 12, 2025

Very much interesting and we did something similar for anndata: scverse/anndata#1959

Feel free to consider our approach that we used there.

@quentinblampey
Copy link
Contributor Author

Oh thanks @Zethson, your approach seems much better and very straightforward, I'll try that!

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.

2 participants