Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial in jupyterhub #328

Open
hyamanieu opened this issue Oct 7, 2022 · 2 comments
Open

Tutorial in jupyterhub #328

hyamanieu opened this issue Oct 7, 2022 · 2 comments

Comments

@hyamanieu
Copy link

hyamanieu commented Oct 7, 2022

Some ideas to improve the tutorial after I've set it up into a jupyterhub environment.

As starting jupyter hub was useless, I did not want to run anaconda-project run jupyter notebook. However packages were missing, so I ran sudo -E anaconda-project run but it seems it does start a notebook nonetheless. What does anaconda-project run do? (yes I know: it was maybe not smart to start as super user an unknown script).

Besides what's already under the "setup" page, I had to install specific packages:

conda activate project
# below two lines is for jupyter to suggest the right environment
sudo -E conda install ipykernel 
sudo -E /opt/tljh/user/envs/project/bin/python -m ipykernel install --name 'holoviz-tuto'
# certainly the last line could be made more flexible as counting on this specific version of tljh

# herebelow missing packages
sudo -E conda install -c pyviz datashader=0.14.0 bokeh=2.4.3 holoviews=1.15.0
sudo -E conda install -c conda-forge numpy=1.21 fastparquet=0.8

I also made a bash script to copy the notebooks but have soft links to the data from a read-only shared folder to the jupyter user home.
I haven't tried the whole tutorial, so I hope there is no mandatory writing back into the other folders besides the tutorial folder.

if [ ! -d ~/holoviz_tutorial/ ]
then
  mkdir ~/holoviz_tutorial
else
  exit 1
fi

echo "copying tutorial notebooks"
cp -R ~/shared/holoviz_tutorial/tutorial ~/holoviz_tutorial
for folder in `ls ~/shared/holoviz_tutorial/`
do
  if [ "$folder" != "tutorial" ]
  then
    echo "linking file or folder $folder"
    ln -s ~/shared/holoviz_tutorial/"$folder" ~/holoviz_tutorial/"$folder"
  fi
done

exit 0
@jbednar
Copy link
Member

jbednar commented Oct 10, 2022

Good question; I'm not sure how best to set this up in jupyterhub. What anaconda-project run <command> does is to:

  1. "Prepare" the environment specified in the anaconda-project.yml file. It's basically the equivalent of conda env create -f anaconda-project.yml (as our anaconda-project.yml files are also valid conda environment files), except that (a) the environment is stored in the current directory so that a project is entirely independent of anything else on your system, and (b) if the envt already exists, any packages specified in the .yml but not already installed are installed.
  2. Activate the conda environment
  3. Run the specified <command> in that environment.

Here if <command> is something defined in the .yml file (e.g. dashboard), the text of that command is used instead, including (if needed) injecting command-line arguments in some cases (e.g. when launching notebooks or dashboards as web services). If <command> isn't defined in that file, it is executed as a command-line command, e.g. echo hello.

In this case you could launch JupyterHub as the command, e.g. anaconda-project run jupyter hub, which would run the entire JH instance in the envt it creates. If the JH is solely for use with this tutorial, that seems like the easy solution. If you want to use the tutorial on an existing JH instance, then I'm not sure how best to define the environment and make it available from within JH, but hopefully the above will make that clear for people who use JH more than I do.

@hyamanieu
Copy link
Author

hyamanieu commented Oct 11, 2022

Thanks for the explanation. I believe anaconda-project is unnecessary in a jupyter hub context.

I could simply suggest a addition to the documentation. Although I am not sure how to deal with the information contained in the yml file, except manually installing the packages.

Idealy requirements are external and can be installed whether using anaconda-project or conda create --file

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

No branches or pull requests

2 participants