trap notebook virtualenv
Gijs Molenaar edited this page Jun 23, 2016
·
2 revisions
# below instructions to install TraP and notebook in a remote virtualenv.
# login into struis with command below. This will start a SSH tunnel which you
# will use later for forwarding you juputer notebook. pick a random number between
# 1024 and 65000 (I picked 8089)
$ ssh -L 8089:localhost:8089 struis.science.uva.nl
# I assume we do everything in the homefolder
$ cd ~
# soooo before you start any virtualenv creation it is important to be sure you
# are *not* already in an active virtualenv. Please make sure you don't have
# activated a virtualenv in this ssh session after you logged in or
# that you activate a virtualenv in your bash login script. You *will* run
# into problems later.
# clone the TKP repo to get the latest code
$ git clone https://github.com/transientskp/tkp
# setup a virtual python environment called 'virtualenv'
$ virtualenv virtualenv
# enable the virtualenv, this will replace your python and pip command
$ source virtualenv/bin/activate
# upgrade pip, latest pip contains a lot of useful tools
$ pip install --upgrade pip
# now to install juputer notebook
$ pip install notebook
# to install tkp (in developer mode, hence the -e)
# developer mode means the git checkout folder is directly linked to
# your installed TKP, which means if you change version (checkout branch or tag)
# you can directly use it
$ cd ~/tkp
$ pip install -e ".[pixelstore]"
# now to start using notebooks make a notebook folder
$ cd ~ && mkdir notebooks $$ cd notebooks
# and start the notebook server. Set the port to the port
# you picked at the start. If already taken pick an other port
# and login again (don't forget to enable your virtualenv again)
$ jupyter notebook --port=8089 --no-browser
# now open your browser and connect to http://localhost:8089
# You can now start hacking. if you are missing a package you can install it with pip.
# this doesn't interfere with any installed packages or any other virtualenvs you might
# have on the same system.
# note that after installing tkp into your virtualenv, the trap-manage.py command
# is also linked to your virtualenv
$ cd ~
$ trap-manage.py initproject pipeline
$ cd pipeline
$ trap-manage.py initjob aartfaac
# By default you checkout and install the latest development version of trap (master).
# you can easily change branch or tag. If you 'git checkout' a specific branch or tag
# you are automatically using that in your virtualenv!
$ cd ~/tkp
$ git tag
r1.0
r1.1
r2.0.0
r2.1.0
r2.1.1
r3.0
r3.0rc
r3.0rc2
r3.1.0
r3.1.1
# if you want to use fo example r3.1.1 just do
$ git checkout r3.1.1
# this will give a warning about detached HEAD state, which is fine in this case.
# if you want to dive more into the active development and see the feature branches
# we are working on:
$ λ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/alembic
remotes/origin/issue492
remotes/origin/master
remotes/origin/monetdb-oct2014-sp4
remotes/origin/nopywcs
remotes/origin/optimizations
remotes/origin/python3
remotes/origin/release1
remotes/origin/release2.0
remotes/origin/release2.1
remotes/origin/release3.1
# if you want to checkout a development branch to verify a bug is solved or not you
# can for example do:
$ git checkout issue492
Branch issue492 set up to track remote branch issue492 from origin.
Switched to a new branch 'issue492'
# that's it! now in the future if you want to start the notebook again, pick a number
# (like 8089) and use it in the commands below:
$ ssh -L 8089:localhost:8089 struis.science.uva.nl
$ source virtualenv/bin/activate
$ cd notebooks
$ jupyter notebook --port=8089 --no-browser
# you can also put everything in one command
$ ssh -L 8089:localhost:8089 struis.science.uva.nl \
virtualenv/bin/jupyter notebook \
--notebook-dir=~/notebooks \
--port=8089 \
--no-browser