This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
other:uvcdat:cdat_conda:ipnb [2019/05/15 09:36] jypeter created |
other:uvcdat:cdat_conda:ipnb [2019/05/15 21:48] jypeter Saved temps notes |
||
---|---|---|---|
Line 29: | Line 29: | ||
* you will use an ipython interpreter | * you will use an ipython interpreter | ||
* in a web browser (rather than a terminal) | * in a web browser (rather than a terminal) | ||
+ | * a notebook is the content of the web page where you have interacted with python. You can save it (''.ppynb'' file) and share it, and it will display both the commands you have used and the output/results of your command | ||
+ | |||
+ | ===== How does it work? ===== | ||
+ | |||
+ | Using an ipython notebooks implies the following steps: | ||
+ | |||
+ | - determine if you will use python on your local computer or a remote computer and //go// to that computer | ||
+ | * the selected computer mostly depends on the data you need to work with. The idea is to move the computation (i.e. python) near the data, and not move/replicate the data | ||
+ | - choose/initialize the distribution and version of python you need to use on the selected computer | ||
+ | * e.g. you can [[other:python:starting#ultra_quick-start_on_the_lsce_servers|use the CDAT distribution on the LSCE servers]] | ||
+ | - start the ipython notebook server with the appropriate parameters (on the selected computer, with the selected python) | ||
+ | * this will start a temporary web server that you can connect to, in order to use the notebooks | ||
+ | * the server will display the URL that you have to use. The URL has an authentication token and only you (or the person who has a copy of the full URL) can connect to your server | ||
+ | * the basic way to start a server is to just type ''jupyter notebook'', but only do this if you want to work locally on your desktop/laptop! See the next section for working on a remote computer | ||
+ | * the ''jupyter notebook'' command will start the notebook server, and it will automatically start a web browser on the same computer. That's OK on your local computer, but on a remote server, the browser will probably seem to be slow (and out of date) and will use unnecessary resources of the server. This will be frustrating for you and the other users of the server | ||
+ | * if you have to work on a remote computer, the idea is to start the ipython server on the remote computer and use a web browser on your local computer (thanks to an //ssh tunnel//) | ||
+ | - in a web browser, open the temporary URL displayed by the ipython server and start using the ipython notebooks | ||
+ | - when you are finished, <wrap em>do not forget to kill the ipython server</wrap> by typing ''^C^C'' (2x ''CTRL-C''). Otherwise the server and the python processes started by the server will keep on using resources on the computer | ||
+ | * Warning! Closing the browser, or using the Logout button in the browser will not stop the ipython server | ||
+ | |||
+ | ===== Working correctly with the notebooks ===== | ||
+ | |||
+ | ==== Reminder ==== | ||
+ | |||
+ | * Make sure you read and understand the [[#how_does_it_work|How does it work?]] section | ||
+ | * If you are doing everything on your own desktop/laptop, you can just start the notebook server and browser with ''jupyter notebook'' | ||
+ | * On a remote and shared server, only start the notebook server and use a local browser to connect to the notebook server through an ssh tunnel | ||
+ | |||
+ | ==== Prerequisite ==== | ||
+ | |||
+ | * | ||
+ | |||
+ | ==== Digging ssh tunnels ==== | ||
+ | |||
+ | The ssh tunnels will allow you to connect a web browser running locally on your computer to a notebook server running on a remote server | ||
+ | |||
+ | === From a local LSCE computer to obelix === | ||
+ | |||
+ | <code>plink -L 7225:localhost:7225 jypeter@obelix | ||
+ | |||
+ | |||
+ | plink -L 7225:localhost:7225 jypeter@obelix | ||
+ | |||
+ | ssh -X -t -L7100:localhost:7100 jypeter@ssh1.lsce.ipsl.fr ssh -L7100:localhost:7100 obelix | ||
+ | |||
+ | plink -X -t -L7100:localhost:7100 jypeter@ssh1.lsce.ipsl.fr ssh -L7100:localhost:7100 obelix | ||
+ | |||
+ | plink -ssh -X -t -L 7100:localhost:7100 jypeter@ssh1.lsce.ipsl.fr ssh -L7100:localhost:7100 obelix | ||
+ | |||
+ | plink -X -t -L 7100:localhost:7100 jypeter@ssh1.lsce.ipsl.fr ssh -L7100:localhost:7100 obelix | ||
+ | |||
+ | ssh -X -t -L 7100:localhost:7100 jypeter@ssh1.lsce.ipsl.fr ssh -L 7100:localhost:7100 obelix | ||
+ | |||
+ | (cdatm_py3) jypeter@obelix3 - ...jypeter - 44 >jupyter notebook --no-browser --port=7100 | ||
+ | [I 23:37:26.017 NotebookApp] [nb_conda_kernels] enabled, 14 kernels found | ||
+ | [I 23:37:26.977 NotebookApp] [nb_conda] enabled | ||
+ | [I 23:37:26.978 NotebookApp] Serving notebooks from local directory: /home/users/jypeter | ||
+ | [I 23:37:26.978 NotebookApp] The Jupyter Notebook is running at: | ||
+ | [I 23:37:26.978 NotebookApp] http://localhost:7100/?token=256f8fa26c8478f136720e0c0c24c4995b6682d9febf6387 | ||
+ | [I 23:37:26.978 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). | ||
+ | [C 23:37:26.992 NotebookApp] | ||
+ | |||
+ | To access the notebook, open this file in a browser: | ||
+ | file:///home/users/jypeter/.local/share/jupyter/runtime/nbserver-1442-open.html | ||
+ | Or copy and paste one of these URLs: | ||
+ | http://localhost:7100/?token=256f8fa26c8478f136720e0c0c24c4995b6682d9febf6387</code> | ||
/* standard page footer */ | /* standard page footer */ |