mbakker7 / timml

An analytic element model for steady multi-layer flow
MIT License
38 stars 21 forks source link

Numba installs fail on _some_ systems, but not all #119

Open kelsonengineering opened 1 month ago

kelsonengineering commented 1 month ago

I'm using timml in a Jupyterlab notebook for my modeling course. Several students have the conda install fail because there is no compatible version of numba. Can anyone offer a suggestion as to how I can correct this?

Thank you!

dbrakenhoff commented 1 month ago

Hi @kelsonengineering, that sounds annoying. My first guess would be to attempt to install an older verison of numpy. Perhaps you could try conda install numpy=1.26.4 or 2.0.2? Then try reinstalling TimML.

But to really answer your question, we'd need a bit more information about the systems the installation is failing on (which OS, and python+package versions). If you're able, could you post some of that information here and we can take a look.

mbakker7 commented 1 month ago

If you could give Python, numpy and numba versions, we will investigate. I always tell the students to do a pip install and haven't run into any problems yet, but we just had a new release which works with the latest numpy.

kelsonengineering commented 1 month ago

Hi Mark!

I've solved the issue. We're using JupyterLab Desktop, which is a pretty good "batteries included" UI for JupyterLab. It has an environment manager, which wants to utilize conda by default, although venv virtual environments are supported. In JupyterLab Desktop, you use the Environment Manager to create the venv, supplying numba, numpy, and timml as Additional Packages, and it works fine. Tested on MacOS, Windows (both Intel and ARM), and Linux on Intel.

After a lot of fiddling around, it appears that conda pins timml to numpy-2.0.2+, and for some systems there isn't a comptible conda package for numba.

Warning - off topic, but not ready to post yet...

Has anyone ever implemented a "river" type line sink in timml? I've reviewed the solver code and it doesn't look too hard. It's really common in the midwest to have percolating rivers and I need them for the term project. If it isn't done already, I'll hack it together and send a PR. If I find time, I might even add the streamflow routing code like ModAEM and GFLOW.

Also, I made a tiny change to my local timml, and it runs black on the Python file after writing the model out to disk. This could also use ruff, but I didn't implement that. Basically, if you have black in your PATH, it all happens automagically. I'll add ruff support and send a PR on that also. It makes the generated code so much more readable.

Thanks! Vic

mbakker7 commented 1 month ago

Hey Vic,

Thanks for solving this problem. What exactly is the solution when using Jupyter Desktop? Does it only work after you create a virtual environment with venv?

Interesting that you use JupyterDesktop for the students. I have thought about that, as it has many advantages. Any downsides?

Regarding your off-topic question of a river element. We would definitely welcome a PR for that. How do you want to solve the nonlinear system?

I am not sure I understand the last suggestion. You write a TimML model and it automatically runs ruff/black? Another option would be to install a Jupyter plugin for that, or are those not available on JupyterDesktop?

Good to hear from you and thanks for the contributions!