csdms / help-desk

The CSDMS Help Desk. Ask questions. Get answers (about CSDMS products and services).
MIT License
6 stars 1 forks source link

Using GeoClaw on Jupyterhub #30

Open rjleveque opened 4 years ago

rjleveque commented 4 years ago

Nice that you have a Jupyterhub set up!

I'm trying it out and have a couple questions. I see from this page that if I submit a lab I could ask to have this software available, but I wonder if there are instructions somewhere for doing these things for a user who wants to use GeoClaw on the JupyterHub without using an existing lab?

  1. I found I could install Clawpack fine by opening a terminal and using git clone, etc., and then in a notebook I can import clawpack.geoclaw fine, and also refer to the CLAW environment variable (used when running the fortran parts of GeoClaw) if I first do this:

    import sys, os
    CLAW = '/home/jupyter-rjleveque/clawpack'
    sys.path.insert(0, CLAW)
    os.environ['CLAW'] = CLAW

    I am wondering if there's a way to set things up so when I come back to my JupyterHub account, my PYTHONPATH and CLAW environment variables are set like this, or will I need to always set these from within a notebook?

    Note: I tried adding these environment variables to /home/jupyter-rjleveque/.bashrc but that didn't affect the environment in a notebook when I restarted the server.

  2. It didn't find gfortran when I tried running this notebook locally, so it died in the compile step. Is there something that needs to be added to the path for this?

mdpiper commented 4 years ago

Hi @rjleveque!

  1. We're using The Littlest JupyterHub (tljh), which doesn't allow environment variables to persist when set through bash. I learned this when I trivially tried to change the awkward default PS1. Instead, there appears to be a mechanism (straight from the tljh dev!) to do so through the JupyterHub installation. I could try these for the Clawpack variables. These variables will be set for all users, though, so I'm a little concerned about setting PYTHONPATH.

  2. I'll install gfortran. Note that we're currently using a single conda environment for the JupyterHub. We'll eventually set up separate environments (and kernels) for groups of related Notebooks (like your GeoClaw Notebooks).

mdpiper commented 4 years ago

gfortran is now available:

$ which gfortran
/opt/tljh/user/bin/gfortran

$ gfortran --version
GNU Fortran (crosstool-NG 1.24.0.123_1667d2b) 7.5.0
rjleveque commented 4 years ago

Great thanks @mdpiper, I'll give it a try.

I agree setting PYTHONPATH isn't good in general and we can easily just set that at the top of a notebook as needed.

It's also possible to use pip to install clawpack rather than setting PYTHONPATH, which is actually the recommended approach for most users. So another option would be to do that globally, so that any user could import it without having to install it themselves.

We could chat about it sometime if you want. Not urgent though!