Skip to content

Conversation

@John-P
Copy link
Contributor

@John-P John-P commented Dec 17, 2021

The aim of this PR (which is a branch off of tidying wsireader.py) aims to make imports only happen as needed where possible. This means that some dependencies can be avoided if they are not required.

On demand imports so far:

  • glymur (and openjpeg)
  • defusedxml

@John-P
Copy link
Contributor Author

John-P commented Dec 17, 2021

@ghadjigeorghiou For a minimal set of requirements, I believe you could skip these:

  • jupyterlab
  • sphinx (we should probably remove this from requirements.txt as it's only needed for dev and docs builds)
  • glymur and openjpeg (if not using JP2)
  • defusedxml if not using TIFFWSIReader (OME)

Other libraries which could fairly easily be made to be imported on demand if desired:

  • albumentions
  • umap-learn
  • matplotlib
  • flask
  • shapely

@codecov
Copy link

codecov bot commented Dec 17, 2021

Codecov Report

Merging #222 (2925edb) into develop (c56b5dc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #222   +/-   ##
========================================
  Coverage    99.81%   99.81%           
========================================
  Files           53       53           
  Lines         4869     4870    +1     
  Branches       800      800           
========================================
+ Hits          4860     4861    +1     
  Misses           2        2           
  Partials         7        7           
Impacted Files Coverage Δ
tiatoolbox/wsicore/wsireader.py 99.12% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c56b5dc...2925edb. Read the comment docs.

@John-P John-P changed the title ENH: Lazy Imports ENH: On Demand Imports Dec 17, 2021
@John-P John-P marked this pull request as ready for review December 20, 2021 15:52
@John-P
Copy link
Contributor Author

John-P commented Dec 20, 2021

I may leave this a just glymur / openjpeg for now, as that makes another non-pip dependency optional, which is nice.

Copy link
Member

@shaneahmed shaneahmed left a comment

Choose a reason for hiding this comment

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

Thanks @John-P

@shaneahmed shaneahmed merged commit 24ae418 into develop Dec 21, 2021
@shaneahmed shaneahmed deleted the enhance-lazy-imports branch December 21, 2021 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants