A quick overview of why to use and how to set up iPython notebooks for research
description
Transcript of A quick overview of why to use and how to set up iPython notebooks for research
ipython notebookfrom scratch. for realsies.
Some basic information to start withiPython notebook is a part of the iPython package (iPython is an improved command line interpreter)
Some basic information to start withiPython notebook is a part of the iPython package (iPython is an improved command line interpreter)
iPython notebook is young, it’s at v2.1 right now.
Some basic information to start withiPython notebook is a part of the iPython package (iPython is an improved command line interpreter)
iPython notebook is young, it’s at v2.1 right now.
Only 1 year ago, iPython notebook was at v0.11
Some basic information to start withiPython notebook is a part of the iPython package (iPython is an improved command line interpreter)
iPython notebook is young, it’s at v2.1 right now.
Only 1 year ago, iPython notebook was at v0.11
In any case iPython notebook has pretty much become *the* tool for data analysis and analysis sharing on the inter webs
Why is that?
Why is that?Easy - Like using the interactive interpreter but now there is the ability to edit, fix, and refactor code.!
Why is that?Easy - Like using the interactive interpreter but now there is the ability to edit, fix, and refactor code.!
Shareable - Easily exported, results are in-line with the page so that it’s easy to see how code turns out.!
Why is that?Easy - Like using the interactive interpreter but now there is the ability to edit, fix, and refactor code.!
Shareable - Easily exported, results are in-line with the page so that it’s easy to see how code turns out.!
Documented - The code and results are both there without necessitating that someone else run it first!
Why is that?Easy - Like using the interactive interpreter but now there is the ability to edit, fix, and refactor code.!
Shareable - Easily exported, results are in-line with the page so that it’s easy to see how code turns out.!
Polyglot - Something works better with bash? R? Ruby? Perl? No problem, run it from iPython notebook!
Documented - The code and results are both there without necessitating that someone else run it first!
Interactive demo time
The basics with an assumption of pyenv
We’ll assume you have the basics, now do: $ pyenv virtualenv 2.7.6 notebook $ pyenv global notebook $ pip install ipython pyzmq tornado
(Using pip then using ipython will install notebook too!)
The basics with an assumption of pyenv
We’ll assume you have the basics, now do: $ pyenv virtualenv 2.7.6 notebook $ pyenv global notebook $ pip install ipython pyzmq tornado
(Using pip then using ipython will install notebook too!)
Or follow this handy blog post:
http://amaral-lab.org/blog/i-wish-i-knew-then-what-i-know-now-lab-notebooks-a
So how can I use this…Start me up on the command line now $ ipython notebook
So how can I use this…Start me up on the command line now $ ipython notebook
Navigate to localhost:8888 in your preferred web browser
So how can I use this…Start me up on the command line now $ ipython notebook
Navigate to localhost:8888 in your preferred web browser
VOILA!
So how can I use this…From the web interface you can create a new notebook
So how can I use this…From the web interface you can create a new notebook
So how can I use this…From the web interface you can create a new notebook
Folders have to be created on the filesystem (terminal or nautilus/finder)
So what is the best way to use this?
Data Exploration
So what is the best way to use this?
Data Exploration
Learning new libraries/techniques
So what is the best way to use this?
Data Exploration
Learning new libraries/techniques
Documenting code/workflow/results
So what is the best way to use this?
Data Exploration
Learning new libraries/techniques
Trying different visualizations
Documenting code/workflow/results
So what is the best way to use this?
Data Exploration
Learning new libraries/techniques
Trying different visualizations
Documenting code/workflow/results
Looking at small/modular parts
What is not a good way to use it?
Greater than 15-20 images in a single notebook
What is not a good way to use it?
Greater than 15-20 images in a single notebook
Poor programming practices(i.e. no functions or modules)
What is not a good way to use it?
Greater than 15-20 images in a single notebook
Poor programming practices(i.e. no functions or modules)
Extensive amounts of *production* code (Think hundreds or thousands of lines)
So how can I set this up…
Holy crap! So many ways!
So how can I set this up…
Holy crap! So many ways!
As a one-off as described!
So how can I set this up…
Holy crap! So many ways!
As a one-off as described!
As a server!
So how can I set this up…
Holy crap! So many ways!
As a one-off as described!
As a server!
As a constantly updating resource!
Initial caveats first
iPython notebook currently has no method of handling two individuals editing the same notebook simultaneously
As a one-offSimply do: $ ipython notebook
As a one-offSimply do: $ ipython notebook
The cool thing is that iPython notebook can now traverse directories
As a one-offSimply do: $ ipython notebook
The cool thing is that iPython notebook can now traverse directories
So *ANY* directory that is a child of the directory where you start the service you can reach it!
As a one-offSimply do: $ ipython notebook
The cool thing is that iPython notebook can now traverse directories
So *ANY* directory that is a child of the directory where you start the service you can reach it!
But! While iPython notebook can create notebooks from the web page it can’t create folders
As a one-off
So this is pretty simple then, you can embed the ipython notebooks in your project directories and navigate to them from your project root $ cd ~
$ nohup ipython notebook &
!
Now navigate to the project code in the browser
But I have to keep switching computers
…and I can’t remember to keep committing repositories.
But I have to keep switching computers
…and I can’t remember to keep committing repositories.
BAM! Solution!
But I have to keep switching computers
…and I can’t remember to keep committing repositories.
BAM! Solution!
Make one folder for ipython notebooks in dropbox!
But I have to keep switching computers
…and I can’t remember to keep committing repositories.
BAM! Solution!
Make one folder for ipython notebooks in dropbox!
But how do I have ipython notebook start in dropbox?
Creating a custom startup directory
Create your profile $ ipython profile create
$ vi ~/.ipython/profile_default/ipython_notebook_config
Change line 551 from: #c.NotebookManager.notebook_dir = u’’
to: c.NotebookManager.notebook_dir = \ u’/home/staff/$USER/Dropbox/Notebooks/’
Kick it up a notch
What if I told you about a world where you could always access your programming environment so long as you had internet?
Kick it up a notch
What if I told you about a world where you could always access your programming environment so long as you had internet?
Or refer to your graphs?
Kick it up a notch
What if I told you about a world where you could always access your programming environment so long as you had internet?
Or refer to your graphs?
Or show your partners/collaborators?
Make a server!
Okay, but hold on there. Here is the HUGE
NUMBER
ONE
RULE
Make a server!
YOU MUST PASSWORD PROTECT IT!
Make a server!
YOU MUST PASSWORD PROTECT IT!
AND NOT WITH YOUR USER PASSWORD!
Make a server!
YOU MUST PASSWORD PROTECT IT!
AND NOT WITH YOUR USER PASSWORD!
MAKE IT A VERYYYY LONG PASSPHRASE
So let’s make a password
Open iPython from your command line (NOT the regular python interpreter!) $ ipython
From Thomas Sileo’s blog
So let’s make a password
Open iPython from your command line (NOT the regular python interpreter!) $ ipython
From Thomas Sileo’s blog
Now set up the profile WITH the password
From Thomas Sileo’s blog
Now set up the profile WITH the password
From Thomas Sileo’s blog
And start that baby up!
Neat idea:Use the server with the notebook directory in your dropbox.
And start that baby up!
Neat idea:Use the server with the notebook directory in your dropbox.
Just copy new data files into dropbox and bam! instant transfer and analysis.