Skip to content

Instantly share code, notes, and snippets.

@jonathanmorgan
Last active November 20, 2020 11:37
Show Gist options
  • Save jonathanmorgan/a6a07dbf9986ccda2628 to your computer and use it in GitHub Desktop.
Save jonathanmorgan/a6a07dbf9986ccda2628 to your computer and use it in GitHub Desktop.
Big Data Basics - tools - IPython and Jupyter
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# tools - IPython and the Jupyter Notebook\n",
"\n",
"For this class, we will all be working through our assigments on a shared linux server. But fear not! We have installed a number of tools to make programming Python on linux easier. The two main ones are IPython and Jupyter Notebook.\n",
"\n",
"# Table of Contents\n",
"\n",
"- [1. the IPython Interactive Interpreter](#1.-the-IPython-Interactive-Interpreter)\n",
"\n",
" - [Launching IPython](#Launching-IPython)\n",
" - [Basic IPython commands](#Basic-IPython-commands)\n",
" - [Running Python Code in IPython](#Running-Python-Code-in-IPython)\n",
" - [IPython Magic Commands](#IPython-Magic-Commands)\n",
" - [An example IPython workflow](#An-example-IPython-workflow)\n",
" \n",
"- [2. the Jupyter Notebook server](#2.-the-Jupyter-Notebook-server)\n",
"\n",
" - [Jupyter Notebook basics](#Jupyter-Notebook-basics)\n",
" - [How a Jupyter Notebook works](#How-a-Jupyter-Notebook-works)\n",
" - [Jupyter Notebook files](#Jupyter-Notebook-files)\n",
"\n",
"- [3. Assignment notebooks](#3.-Assignment-notebooks)\n",
" \n",
" - [The Assignments tab in Jupyter](#The-Assignments-tab-in-Jupyter)\n",
"\n",
" - [Downloading Assignments](#Downloading-Assignments)\n",
" - [Working on Assignments](#Working-on-Assignments)\n",
" - [Handing in Assignments](#Handing-in-Assignments)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1. the IPython Interactive Interpreter\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"The IPython interactive interpreter (IPython) is a character-based programming environment that allows you to interactively type out Python programs, line by line, running each line as you go. This might not sound that awesome, but if you know how and when to use it, it can be a big help. Building Python programs line by line lets you easily test code line by line, as you write it, and lets you look at the state of your program as you go.\n",
"\n",
"IPython also implements an additional set of useful \"magic commands\" that help you to manage files, log output from your programs, and test and debug your code.\n",
"\n",
"The IPython interactive Python interpreter isn't the prettiest way to run Python code, but when combined with another program named \"GNU screen\", it is a good way to work with and test long-running Python programs (where long-running = days or even weeks - that is one way you know you have big data...).\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Launching IPython"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"To run IPython, while you are logged in to a command shell on the server, type `ipython` at the unix prompt.\n",
"\n",
"```\n",
"jmorgan@ip-172-31-36-239:~$ ipython\n",
"Python 2.7.9 |Anaconda 2.1.0 (x86_64)| (default, Dec 15 2014, 10:37:34) \n",
"Type \"copyright\", \"credits\" or \"license\" for more information.\n",
"\n",
"IPython 2.3.1 -- An enhanced Interactive Python.\n",
"Anaconda is brought to you by Continuum Analytics.\n",
"Please check out: http://continuum.io/thanks and https://binstar.org\n",
"? -> Introduction and overview of IPython's features.\n",
"%quickref -> Quick reference.\n",
"help -> Python's own help system.\n",
"object? -> Details about 'object', use 'object??' for extra details.\n",
"\n",
"In [1]: \n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basic IPython commands\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"Basic IPython commands:\n",
"\n",
"- introduction: [http://ipython.org/ipython-doc/2/interactive/tutorial.html](http://ipython.org/ipython-doc/2/interactive/tutorial.html)\n",
"- `?` = overview of features\n",
"- `%quickref` = Python quick reference.\n",
"- add `“?”` after a variable reference - details on that variable.\n",
"- `“??”` = extra details.\n",
"- `help` = python’s built-in help system."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Running Python Code in IPython\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"First, lets try running a few simple python commands in the IPython interactive Python shell.\n",
"\n",
"Print something to the screen:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print( \"Something to the screen\" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Declare a variable, then print its contents to the screen."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"test_text = \"\"\n",
"test_text = \"Hello!\"\n",
"print( test_text )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And then we'll see what simply entering a variable name at the prompt does:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"test_text"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test to see if we installed an external package (beautiful soup, used to programmatically interact with the HTML that makes up web pages) correctly such that we can import it:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from bs4 import BeautifulSoup"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When you import, no output at all = no errors = success (and more on Beautiful Soup later, if you are interested)!\n",
"\n",
"For now, `quit` out of IPython, but leave your shell open."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"quit"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## IPython Magic Commands\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"IPython \"magic commands\" let you run a set of useful commands in addition to Python, including basic operating system commands to manage files like those we played with in the shell (though not all of them) and commands to help you run, log messages from, and debug python programs.\n",
"\n",
"Examples:\n",
"\n",
"- _`pwd`_\n",
"- _`ls -al`_\n",
"- _`cd`_ - **_c_**hange **_d_**irectory - when used alone, takes you back to your home directory (`/home/<username>`)\n",
"- _`mkdir work`_ - **_m_**a**_k_**e **_dir_**ectory - in the current directory (as output by `pwd`) creates a new directory named \"work\".\n",
"- _`cd work`_ - **_c_**hange **_d_**irectory to a specific directory (in this case, `work`).\n",
"- `%run <path_to_python_code_file>` - lets you run the contents of a file full of python code, leaving all variables in the program still available in IPython after the code in the file is run, for debugging purposes. This is great for working with programs in IPython once they get too complicated to just type in by hand.\n",
"\n",
"Magic commnds are technically all preceded by a percent sign (`%`). The `cd`, `ls`, `pwd`, `mkdir`, etc. commands above that work in IPython just like they do in the shell are actually magic commands, too. The default behavior of IPython is to check commands to see if they are magic, even if they don't have a \"%\" at the beginning, and run the magic command if it finds a match. Be aware. (and try them with a percent in front of them if you'd like).\n",
"\n",
"There are many more magic commands built into IPython, and you also have the ability to add 3rd party magic commands, or create your own. If you are interested in learning more about IPython magic commands:\n",
"\n",
"- IPython tip sheet by Chris Myers of Cornell - [http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python/ipython.html](http://pages.physics.cornell.edu/~myers/teaching/ComputationalMethods/python/ipython.html)\n",
"- IPython magic command documentation - [http://ipython.org/ipython-doc/stable/interactive/reference.html#magic-command-system] (http://ipython.org/ipython-doc/stable/interactive/reference.html#magic-command-system)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## An example IPython workflow\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"Overview:\n",
"\n",
"In this example workflow, you'll be coding on your desktop in your editor of choice, moving the Python files you create over to the server as you make changes using an SFTP program (FileZilla is a good, easy, free, and stable choice), and then using a shell to connect to the server and run your programs in IPython.\n",
"\n",
"### Setup\n",
"\n",
"#### Filezilla\n",
"\n",
"First step is to download and install Filezilla on your computer. You can download Filezilla from [https://filezilla-project.org/download.php?type=client](https://filezilla-project.org/download.php?type=client). There is a big green download button that should work just fine, or if you want make sure you get exactly the right version for your OS, you can click the [Show additional download options](https://filezilla-project.org/download.php?show_all=1) link and download a specific installer from there. Once you've downloaded it, run the installer.\n",
"\n",
"#### Code editor\n",
"\n",
"You'll also want to get a reasonable code editor, one that at least chroma-codes the text in your code file. A good one that is free to try as long as you want to evaluate it (though you should buy it if you really like it) is Sublime Text. I'd recommend you use version 3: [http://www.sublimetext.com/3](http://www.sublimetext.com/3).\n",
"\n",
"#### `work` folders\n",
"\n",
"On your computer and on the server make folders where you'll be doing your work. I usually call the folder `work`. On my computer, I place the work folder in `Documents` or `My Documents`, depending on the OS. On the server, I usually make a `work` folder directly in my home directory.\n",
"\n",
"### Basic workflow\n",
"\n",
"- on your computer, in your work folder, put python code you want to run into a python file (for this example, we'll call it `test.py`).\n",
"- use Filezilla to move that file over to your work folder on the server.\n",
"- open an SSH connection to the server (using putty on windows, or Terminal on OS X).\n",
"- cd into your work folder:\n",
"\n",
" cd work\n",
"\n",
"- run ipython:\n",
"\n",
" ipython\n",
"\n",
"- In IPython, use `%run <file_name>` the file. So, if your file was `test.py`:\n",
"\n",
" %run test.py\n",
"\n",
"- The code will run, and you'll be able to subsequently use IPython to look at the values in variables, interact with the results, etc.\n",
"- make changes as needed on your computer, re-upload the file, and re-run it as needed.\n",
"\n",
"### Long-running code\n",
"\n",
"If you have a program you'll need to run for a long time, there is an additional step that will let you run your program in the background, even if you log out or are disconnected from the server (because your internet goes out, for example): **_use GNU screen to create a background server session._**\n",
"\n",
"To use `screen`, you'll just run the `screen` command as soon as you log in to a shell on the remote machine. So, your workflow becomes:\n",
"\n",
"- on your computer, in your work folder, put python code you want to run into a python file (for this example, we'll call it `test.py`).\n",
"- use Filezilla to move that file over to your work folder on the server.\n",
"- open an SSH connection to the server (using putty on windows, or Terminal on OS X).\n",
"- either create or reconnect to a screen session.\n",
"\n",
" - If there is no currently running screen session, create a new one:\n",
" \n",
" screen\n",
" \n",
" - If there is a currently running screen session, reconnect:\n",
" \n",
" screen -r\n",
" \n",
" - If there is a currently running screen session and the server thinks someone is already connected to it, force screen to take over:\n",
" \n",
" screen -r -f\n",
"\n",
"- If you created a new screen session:\n",
"\n",
" - check what folder you are in. If not `work`, cd into your work folder:\n",
"\n",
" pwd # if not ~/work, then:\n",
" cd work\n",
"\n",
" - run ipython:\n",
"\n",
" ipython\n",
" \n",
"- If you rejoined an existing screen session, you are probably already in your work directory, and likely already in ipython. If not, adjust as needed.\n",
"\n",
"- In IPython, use `%run <file_name>` the file. So, if your file was `test.py`:\n",
"\n",
" %run test.py\n",
"\n",
"- The code will run, and you'll be able to subsequently use IPython to look at the values in variables, interact with the results, etc. If your code is going to run for a long time:\n",
"\n",
" - to disconnect from screen, type `Control` + `A`, then the letter `D` immediately after you let up from Control and A.\n",
" \n",
" - to reconnect, log in and run `screen -r`.\n",
"\n",
"- make changes as needed on your computer, re-upload the file, and re-run it as needed.\n",
"- for more information on GNU screen:\n",
"\n",
" - The official GNU screen manual - [http://www.gnu.org/software/screen/manual/screen.html](http://www.gnu.org/software/screen/manual/screen.html)\n",
" - screen quick reference - [http://aperiodic.net/screen/quick_reference](http://aperiodic.net/screen/quick_reference)\n",
" - O'Reilly screen guide - [http://archive.oreilly.com/linux/cmd/cmd.csp?path=s/screen](http://archive.oreilly.com/linux/cmd/cmd.csp?path=s/screen)\n",
" - ARCH Linux screen guide - [https://wiki.archlinux.org/index.php/GNU_Screen](https://wiki.archlinux.org/index.php/GNU_Screen)\n",
"\n",
"### Prototyping\n",
"\n",
"Prototyping or implementing new features over time:\n",
"\n",
"- sometimes, for simple things (testing API libraries for example), I will go line by line in IPython. As soon as you start looping or defining functions, however, I break it out into a file.\n",
"- Then, once it is working, I take the contents of the file and integrate them into project - function, methods, or objects, depending. \n",
"\n",
"<hr />"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2. the Jupyter Notebook server\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"Next, we are going to get to know Jupyter Notebooks, which we'll be working with on our class Jupyter Notebook server. What you ask, is a Jupyter Notebook?\n",
"\n",
"From [http://jupyter.org/](http://jupyter.org/):\n",
"\n",
"\"The Jupyter Notebook is a web-based interactive computing platform that allows users to author data- and code-driven narratives that combine live code, equations, narrative text, visualizations, interactive dashboards and other media.\"\n",
"\n",
"It makes a little more sense if I show you. This presentation is a Jupyter Notebook. Remember the Python code above we entered into IPython? Since this is a Jupyter Notebook, and I am actually connected to a Python kernel on the server (as you will be in a few minutes here), I can run the commands in real-time.\n",
"\n",
"On our server, we use software called jupyterhub to provide each of you with a space to make and use Jupyter Python Notebooks. Assignments will be Jupyter Python Notebooks, distributed and collected through the jupyterhub, with sections in which you'll complete and test code that we'll then grade. You'll also be able to upload and run Jupyter Python Notebooks. So, for example, when class presentations are implemented using Jupyter notebooks, you'll be able to follow along and play with the code as the instructor presents it.\n",
"\n",
"To login to jupyterhub so you can use Jupyter Notebooks:\n",
"\n",
"- go to [https://bigdataforsocialscience.com:8000](https://bigdataforsocialscience.com:8000)\n",
"- log in with your unix server `<username>` and `<password>`.\n",
"\n",
"Once you log in, you should see the jupyterhub Home screen, something like this (though perhaps without the adorable birds):\n",
"\n",
"<img src=\"http://data.jrn.cas.msu.edu/images/jupyter_home.png\" />\n",
"\n",
"Once you are logged in to jupyterhub, you can:\n",
"\n",
"- Use the \"Files\" tab, pictured above, to create new Jupyter Python Notebooks, upload and run notebooks you find on the Internet (though be careful what you donwload and run), and work on assignments you have downloaded from...\n",
"\n",
"<img src=\"http://data.jrn.cas.msu.edu/images/jupyter_assignments.png\" />\n",
"\n",
"- the \"Assignments\" tab, where you can see and download assignments that have been released, submit assignments once you are done with them, and keep track of assignments you have submitted.\n",
"\n",
"Let's download the Jupyter notebooks for today's boot camp to our computers, then upload them to the server, so you can run subsequent code examples as we go.\n",
"\n",
"- First, open each of the Jupyter Notebooks we are working on today:\n",
"\n",
" - [tools-unix_shell_and_commands.ipynb](http://nbviewer.ipython.org/gist/jonathanmorgan/08f35e4880287dbe77f6)\n",
" - [tools-ipython_jupyter.ipynb](http://nbviewer.ipython.org/gist/jonathanmorgan/a6a07dbf9986ccda2628)\n",
" - [intro_to_python.ipynb](http://nbviewer.ipython.org/gist/jonathanmorgan/fb5e16049bf4617b2d3d)\n",
" - [good_coding_habits.ipynb](http://nbviewer.ipython.org/gist/jonathanmorgan/0e0cb8d4a9bdfb9519ce)\n",
"\n",
"- To download the source for a notebook:\n",
"\n",
" - click the download button (see lovingly annotated image below). This will display the JSON source for the file in your browser window.\n",
" - in your browser, in the \"File\" menu, click \"Save Page As\" (this could vary a bit depending on the browser you are using). Specifically:\n",
"\n",
" - On a Mac, using Safari, you'll need to:\n",
" \n",
" - in the \"Save As\" dialogue, make sure to choose \"Format\" of \"Page Source\", NOT \"Web Archive\"\n",
" - then, in the \"Save Plain Text\" pop-up that will appear when you click \"Save\", click \"Don't append\" to tell it to NOT append \".txt\" to the end of the file name (you want to keep the \".ipynb\" extension).\n",
"\n",
" - save the file on your Desktop.\n",
"\n",
"### Download Source\n",
"<img src=\"http://data.jrn.cas.msu.edu/images/download_ipynb.png\" />\n",
"\n",
"### Download - Safari - Save As\n",
"<img src=\"http://data.jrn.cas.msu.edu/images/jupyter/jupyter_safari_save_as.png\" />\n",
"\n",
"### Download - Safari - Append \".txt\"?\n",
"<img src=\"http://data.jrn.cas.msu.edu/images/jupyter/jupyter_safari_append.png\" />\n",
"\n",
"- To upload a file to the server:\n",
"\n",
" - go to your Jupyter Home page.\n",
" - for each `*.ipynb` file:\n",
" \n",
" - In the \"Files\" tab, click the \"Upload\" button in the upper right corner.\n",
" - in the upload dialogue box that pops up, find and select the file.\n",
" - click the \"OK\" button (or equivalent) to upload it to the server.\n",
"\n",
" - Once it is uploaded, it should appear in the Files tab, in the file list to the left.\n",
"\n",
"- To work with a notebook, click on its name in the File list and it will open in a separate tab in your browser, just like it is running on my computer."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Jupyter Notebook basics\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"There are three basic types of cells in a Jupyter Notebook:\n",
"\n",
"- **code** - can contain Python commands and/or IPython magic commands, used just as you would a basic IPython Interactive Interpreter. To run the commands in a cell, press the black triangular \"Play\" button in the menu-bar at at the top of the web app. The commands will run and their output will be placed inline after the cell.\n",
"\n",
" - more information - Jupyter documentation on \"Running Code\": [http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Notebook/Running%20Code.ipynb](http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Notebook/Running%20Code.ipynb)\n",
"\n",
"- **markdown** - contains text in the markdown formatting language. The contents will be rendered when you run the cell.\n",
"\n",
" - more info on markdown cells: [http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Notebook/Working%20With%20Markdown%20Cells.ipynb](http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Notebook/Working%20With%20Markdown%20Cells.ipynb)\n",
" - markdown syntax: [http://daringfireball.net/projects/markdown/syntax](http://daringfireball.net/projects/markdown/syntax)\n",
"\n",
"- **headers** - headers are actually just markdown cells, so you can either put headers in a \"header\" cell, or just put them where you want them in \"markdown\" cells. They turn into links when they are run, and they can be used to make tables of contents. They use markdown header syntax: the number of pound signs before the header is the level of the headline - One pound sign (#) is an H1 (the largest headline), two pound signs (##) is an H2 (second largest), etc.\n",
"\n",
"When you are editing a notebook, you can insert cells into a notebook after the currently selected cell (the \"plus\" button), then move them up (the \"up arrow\" button) and down (the \"down arrow\" button) or copy and paste them. To edit an existing cell, double-click on the cell. To run the code in a cell, or to render the markdown, or to format a header and convert it to a link, click the black \"Play\" triangle button in the Jupyter Notebook menu bar.\n",
"\n",
"<img src=\"http://data.jrn.cas.msu.edu/images/jupyter/jupyter_cell_buttons.png\" />\n",
"\n",
"Good beginner documentation:\n",
"\n",
"- Jupyter Notebook basics: [http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Notebook/Notebook%20Basics.ipynb](http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/Notebook/Notebook%20Basics.ipynb)\n",
"- Jupyter Notebook examples: [http://nbviewer.ipython.org/github/ipython/ipython/tree/master/examples/Notebook/](http://nbviewer.ipython.org/github/ipython/ipython/tree/master/examples/Notebook/)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How a Jupyter Notebook works\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"A Jupyter Notebook is a little more complicated than an IPython session. It consists of two pieces:\n",
"\n",
"- a Jupyter server and Python kernel that:\n",
"\n",
" - run python code from the notebook on the server, then return the results to you.\n",
" - track and stores changes to your ipython notebook as you edit it.\n",
"\n",
"- a web application that you run in a web browser that talks to the Jupyter server and lets you view and interact with Jupyter Notebooks.\n",
"\n",
"More details:\n",
"\n",
"- a Jupyter Notebook is still saved in a text file, but not an easily readable one - JSON structured data.\n",
"- Jupyter Notebooks capture all input and output, giving you better logging than %logstart in the IPython Interpreter.\n",
"- Jupyter Notebooks are useful for mixing formatted output, text, images, etc. with code and logged output:\n",
"\n",
" - you can insert pictures, and can include rendered graphics generated by python code.\n",
" \n",
"And, a little history:\n",
"\n",
"- It is based on the same technology, and was only recently renamed to \"Jupyter Notebook\" from \"IPython Notebook\" when the developers separated the notebook functionality from IPython, so they could run notebooks with other programming languages like R or Julia using the Jupyter server as well."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Jupyter Notebook files\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"More details on the Jupyter Notebook file format:\n",
"\n",
"- Jupyter Notebook files have the file extension of \"`*.ipynb`\".\n",
"- They are saved in their entirety to the file system as JSON (a way of using plain text to record structured data).\n",
"\n",
" - Example - [http://nbviewer.ipython.org/gist/jonathanmorgan/08f35e4880287dbe77f6](http://nbviewer.ipython.org/gist/jonathanmorgan/08f35e4880287dbe77f6).\n",
"\n",
"- As was outlined above, you can upload Jupyter notebooks to the class server to interact with and edit them.\n",
"- You can also use the online notebook viewer at http://nbviewer.ipython.org to view Jupyter Notebooks stored as a github GIST (a single file repository) or placed on a web server, so they can be viewed even if the user doesn't have access to a Jupyter server on their local computer.\n",
"\n",
" - when viewing Jupyter Noteboooks in this way, you can download a copy to your local desktop so you can look at how it is coded, use it as a template, etc.\n",
" - _suggestion:_ Download Jupyter Notebook files you see and think are useful, in case they either disappear or are subsequently altered beyond recognition.\n",
"\n",
"- Notebooks can also be exported to flat HTML or PDFs, but these transformations can be a little hard to set up. You'll need pandoc or node.js installed, and even then, you might have to do some relatively substantial troubleshooting. I got it to work on my mac by installing pandoc using homebrew, but I am still working on getting it to work in windows."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3. Assignment notebooks\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"The Jupyter notebooks we will be working in for assignments are standard notebooks with a few additions. Certain cells in the notebook are designated as answer cells, and the code or information you place in answer cells will be graded to assess your performance on assignments.\n",
"\n",
"Please do not delete answer cells from one of your assignment notebooks. I am not sure what will happen, but it is likely you will add complexity to getting your assignment turned in and graded.\n",
"\n",
"## The Assignments tab in Jupyter\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"<img src=\"http://data.jrn.cas.msu.edu/images/nbgrader/nbgrader-assignments_tab.png\" />\n",
"\n",
"### Downloading Assignments\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"Assignment notebooks available for download are listed in the \"Released Assignments\" section of the \"Assignments\" tab, the top section. To download a released assignment, click the \"Fetch\" button. After a few seconds, the assignment should disappear from the \"Released Assignments\" section and then appear in the \"Downloaded Assignments\" section.\n",
"\n",
"### Working on Assignments\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"Once an assignment is in the \"Downloaded Assignments\" section of the \"Assignments\" tab, you'll be able to view all the Jupyter notebooks that make up the assignment.\n",
"\n",
"To see the Jupyter notebooks associated with a given assignment, click the little triangle button to the right of the assignment name in the \"Downloaded Assignments\" section of the \"Assignments\" tab. This will drop down all the Jupyter notebooks associated with the assignment.\n",
"\n",
"To work on one of the Assignment notebooks, click on it. This will open it in a new browser tab. You can also find the assignments in the file tab. Each assignment you download is placed in a directory in your home folder. The directory is named the same as the Assignment. Inside this directory are all of the Jupyter notebooks for the assignment. You can also navigate into a given assignment's folder and click on an Assignment notebook there to work on a part of an assignment.\n",
"\n",
"### Handing in Assignments\n",
"\n",
"- [Back to Table of Contents](#Table-of-Contents)\n",
"\n",
"Once you have completed an assignment, there are two steps to handing it in:\n",
"\n",
"- 1) **Validate the Assignment notebooks,** to make sure you answered all the questions:\n",
"\n",
" - go to the Assignments tab and in the \"Downloaded Assignments\" section, drop down the list of Jupyter notebooks associated with the assignment you want to turn in.\n",
" - There will be a \"Validate\" button to the right of each. For each notebook, click the \"Validate\" button.\n",
" - Validation will result in a message and change of the color of the \"Validate\" button for each notebook you validate. If a notebook passes, the message will tell you so, and the \"Validate\" button will turn green. If a notebook fails, the message will tell you what problems it found, and the \"Validate\" button will turn red.\n",
" - If your Assignment notebooks fail validation, please work through the problems until they validate successfully.\n",
"\n",
"- 2) **Submit the assignment.** When you submit an assignment, all the notebooks for that assignment are pushed back to the grading application to be graded. To submit an assignment, click the \"Submit\" button to the right of the assignment. The assignment will remain in the \"Downloaded Assignments\" section, but a line for it will appear in the \"Submitted Assignments\" section of the \"Assignments\" tab as well, with the date and time the assignment was submitted.\n",
"\n",
" - Assignments can be submitted more than once. If you submit your assignment, then realize you made a huge mistake that you want to correct, edit and update the Assignment notebooks, validate them, then click the Submit button again. This will replace your submission in the grading system.\n",
" \n",
"**_NOTE: If you made copies of an Assignment notebook as backups, the only copy that will be submitted is the one with the original name. Make sure that the Assignment notebook with the original name is the one that has your completed assignment in it._**"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment