Day 4 - Thursday, April 10, 2014

Summary: ssh'ing to dirac, more iPython, ipythonblocks


1. Open a Terminal window and learn how to connect to a remote computer (in this case, the dirac cluster) using ssh (secure shell).

ssh is a program that encrypts all communications between the local and remote computer. Because graphical information is data-intensive, ssh does not allow remote graphics by default. In order to force ssh to forward graphical output, we have to give it the flag -X, that stands for "X forwarding". "X" is the graphical windowing system used on UNIX machines, such as the dirac cluster. Here is the command we enter to log onto dirac5:

 $ ssh -X <username>@dirac5.calpoly.edu

This command will work from any networked Mac or linux machine with ssh installed. For Windows users, you need to install two pieces of software to be able to use dirac. First, an ssh client program like PuTTy and then an X-windowing system like Xming.

2. Once we are logged onto dirac for the first time, we have to set up our environment to have the paths to all of the programs we want to run in our PATH variable. Instead of having everybody type in the contents of the .bash_profile file, we can use the copy command cp, to copy jklay's file to our home directory. To do that enter the following command:

$ cp ~jklay/.bash_profile .

The ~jklay part is a shortcut to jklay's home directory. This same shortcut will work for any user account on the machine. The "dot" at the end of the command tells the copy command to copy the file with the same name as the source file in the current directory. As we have seen, the general form of the command is

$ cp <source> <target>

where the source is a file and the target can be either a new filename, a path to a directory or a path plus filename. Since we just created the file, our environment hasn't been configured yet. Either log out and back in again or source the file so that the aliases and PATH are set for the current session:

$ source .bash_profile

3. We can clone our github repository to dirac so that whenever we work on that machine, we have our repository available.

$ git clone https://github.com/<github-username>/<github-reponame>.git

This is the standard git checkout command, or you can open a browser window and copy the link directly from your github site.

Set up the global configuration of git by cd-ing to the repository directory and source-ing the configure script:

$ cd PHYS202-S14
$ source ConfigureGit.sh

4. Verify that you can run the ipython notebook with our newly configured environment.

$ ipynb

This opens a firefox session on dirac, but the graphical window appears on our local machine. When we are done, we can close the firefox window and type <ctrl>-c once or twice in the terminal window to stop the python kernal and to get the command line prompt back.

5. Before logging out of dirac, practice the workflow of checking the git status and making sure our local (on dirac) changes are in sync with the rmote (github) repository.

$ cd PHYS202-S14
$ git status
$ git add <ANY MODIFIED/CREATED FILES>
$ git commit -m "<MESSAGE>"
$ git push origin master
$ git status
$ exit

To log out of dirac type exit at the command line prompt. Now we are back on our local (180-272) computer again. Check the git status of the local (180-272) repository before proceeding to work.

$ cd
$ cd PHYS202-S14
$ git status
$ git pull origin master
$ ipynb

6. More on iPython (selections from Vanderplas 03 and 04)

Use the iPythonIntro notebook.

  • Basic navigation
  • Accessing the underlying OS
  • Magic functions
  • Error display
  • raw_input
  • Modules

7. Visual coding with ipythonblocks

Use the FunWithBlocks notebook.

See the demo at "http://nbviewer.ipython.org/github/jiffyclub/ipythonblocks/blob/master/demos/ipythonblocks_demo.ipynb" and another person's take on it at "http://nbviewer.ipython.org/github/catherinedevlin/mpwfw_exercises/blob/master/blocks.ipynb" (includes fun exercises).

8. Finally, before leaving, close the notebook session and save your changes to github:

$ git add <ANY MODIFIED/CREATED FILES>
$ git commit -m '<MESSAGE>'
$ git push origin master

Any unfinished exercises are assigned for homework due on Wednesday, 16-Apr-2013 at 11:59pm.

HW:

Complete the full Python track in Codecademy by Monday, 11:59pm. The ones we haven't been assigned yet include:

  • Exam Statistics
    • 16. Exam Statistics
  • Advanced Topics in Python
    • 17. Advanced Topics in Python
    • 18. Introduction to Bitwise Operators
  • Introduction to Classes
    • 19. Introduction to Classes
    • 20. Classes
  • File Input and Output
    • 21. File Input and Output

Be sure you have completed all 21 lessons and the follow-up exercises by the deadline. Go back and complete any unfinished ones.

EMAIL THEM

  • Homework (Codecademy)
  • Installfest announcement
  • Instructions for ssh/PuTTy/Xming
  • Installation instructions

Post to Polylearn

  • Installation instructions
  • ssh instructions
  • iPythonIntro Notebook
  • FunWithBlocks Notebook

All content is under a modified MIT License, and can be freely used and adapted. See the full license text here.