OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
231 stars 113 forks source link

Leaner dependencies #1280

Open poplarShift opened 2 months ago

poplarShift commented 2 months ago

Hei, I'm frequently frustrated by the extensive imports that opendrift requires. While I am happy to disregard the environment/requirements file that is shipped with opendrift, for running a simple tracking experiment one should not require imports of matplotlib, colored logs, cmocean, etc. etc.

I am happy to make a draft PR but would be happy to hear your opinions first. Are simple try/except clauses with the appropriate warnings good enough for you or would you like some more advanced system with e.g. flags?

knutfrode commented 2 months ago

Hi,

We agree that a bare minimum of imports should be made. We are planning on moving most of the analysis functionality (including plotting/animations) out of OpenDrift and into the TrajAn tool, which could help to avoid importing e.g. matplotlib for doing a simulation. Presently plot-methods are in the basemodel module, and therefore libraries for plotting are also imported at the top of that module, according to PEP8: https://peps.python.org/pep-0008/#imports

Pull requests for limiting unnecessary imports are welcome. But probably best if you first make a small example PR, as @gauteh and myself could have some opinions or suggestions before merging major changes.