Lecture #2: Setting up your Development Environment

Here is what I intend to cover today:

  • Python Basics
  • What is Interactive Python (IPython)?
  • What are IPython Notebooks?
  • What are Hosted IPython Notebooks (like wakari.io)?
  • How do I make my code available to others (git)?
  • What is GitHub?

At the end of this process, I would like for each of you to be able to create an IPython Notebook locally on your computer, edit it on Wakari.io, and then be able to allow anyone else to see it using GitHub's IPython Notebook Viewer.

This very same file we have on the screen now will make that journey.

Before you begin

Things you'll need to do ahead of time:

  1. Create an account on wakari.io
  2. Create an account on github.com
  3. Install the Anaconda Python distribution (Optional, if you want to edit files locally on your computer)
  4. Install git on your computer, which you can get here (Optional too, only if oyu want to interact with git repositories from your computer)

Some references that will be very helpful to ensure you understand what we are doing and how it all works:

  1. Git References
    • What it is and what is it used for?
      • Official Documentation, especially the first three videos on this page.
      • Official Git Tutorial, if you are already familiar with the command line interface to some other version control software and just need to get started.
    • How does it work?
  2. Wakari and Python References

OK. Let's get you started.

Cloning the course's git repository

This file you are currently viewing is part of the course's git repository, which you can find here:

http://github.com/marioberges/courses_12-752/

Since it is in a public repository, you should be able to clone that repository into your computer and edit each file locally. For that, you could either clone it using the command line interface to git, or a graphical user interface (whichever you installed on your computer if you chose to install git). From the command line, for instance, you would issue this command to clone it:

git clone http://github.com/marioberges/courses_12-752.git

If you are planning to edit IPython Notebooks locally on your computer (and not with Wakari.io), then make sure that you can clone the repository into your computer by issuing that command.

If you are successful, you will be able to see a new folder called courses_12-752 inside the folder where you issued the command. A copy of this IPython Notebook file should be in there as well, and you can view it by opening an IPython Notebook Server as follows:

ipython notebook

Just make sure you issue this last command on the corresponding folder.

Cloning the repository on the Wakari.io server

Now let's test if you can also do this on Wakari.io. In other words, we will be cloning the class git repository into your Wakari.io environment, so that the files (including this notebook) are accessible to you on Wakari.io and you can use the IPython Notebook there to edit files and do whatever you like.

All you need to do is to go to Terminal mode on Wakari.io, and launch a new "Shell" terminal. Once there, you can use the same command we had issued earlier to clone the repository:

git clone http://github.com/marioberges/courses_12-752.git

If you were successful in doing this, then you will see a new folder appear on the left hand side of the screen (the folder view) called courses_12-752. You may need to hit the refresh button to see it.

Now you can open that folder and load the IPython Notebook file for this lecture and edit it in Wakari.io

Creating and using your own repositories

The steps we followed above were for cloning the course's official repository. However, you will want to repeat these steps for any other repository you may be interested in working with, especially the ones that you end up creating under your Github account. Thus, let's practice importing one of your repositories.

Follow these steps:

  1. Head over to github.com and log in using your credentials.
  2. Create a new repository and name it whatever you like.
  3. At the end of the process you will be given a checkout string. Copy that.
  4. Use the checkout string to replace the one we used earlier that looked like this:
     git clone http://github.com/yourusername/yourrepository.git
  5. Try issuing that command on your Wakari.io terminal (obviously, replacing yourusername and yourrepository with the right information)
  6. If all goes well, you'll have your (empty) repository available for use in Wakari.io.

Now it's time for you to practice some of your recently learned git skills.

Create a new IPython notebook in Wakari.io, making sure to place it inside the folder of the repository you just cloned.

Add a couple of Python commands to it, or some comments, and save it.

Now go back to the terminal and add, commit and push the changes to your repository:

git add yourfile.ipynb
git commit -m "Made my first commit"
git push origin master

If this worked, you should be able to see the file added to your repository by simply pointing your browser to:

http://github.com/yourusername/yourrepository

Doing away with the terminal

Because IPython can be used to issue commands to a shell, directly, you can avoid having to switch to a terminal screen if you want to. This means we could have performed all of the above git manipulation directly from this notebook. The trick is to create a Code cell (the default type of cells) in the IPython notebook and then issuing the commands preceded by a ! sign, as follows:


In [1]:
!git status


On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   Lecutre2.ipynb

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	../.bundle/
	../.ipynb_checkpoints/
	../Gemfile
	../lecture2_live.ipynb
	.ipynb_checkpoints/

no changes added to commit (use "git add" and/or "git commit -a")

Try running the above cell and see what you get.


In [ ]: