{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "# Hello World\n",
    "<br>Owner(s): **Phil Marshall** ([@drphilmarshall](https://github.com/LSSTScienceCollaborations/StackClub/issues/new?body=@drphilmarshall)), **Greg Madejski** ([@Madejski](https://github.com/LSSTScienceCollaborations/StackClub/issues/new?body=@Madejski))\n",
    "<br>Maintainer(s): **Alex Drlica-Wagner** ([@kadrlica](https://github.com/LSSTScienceCollaborations/StackClub/issues/new?body=@kadrlica)) \n",
    "<br>Last Verified to Run: **2021-03-31**\n",
    "<br>Verified Stack Release: **21.0.0**\n",
    "\n",
    "### Learning Objectives:\n",
    "\n",
    "After working through this tutorial you should be able to:\n",
    "\n",
    "1. Edit a notebook in the `JupyterLab` environment\n",
    "2. Commit and push those changes back to a development branch, having learned the Stack Club `git`/GitHub workflow.\n",
    "\n",
    "### Logistics\n",
    "This notebook is intended to be runnable on `lsst-lsp-stable.ncsa.illinois.edu` from a local git clone of https://github.com/LSSTScienceCollaborations/StackClub.\n",
    "\n",
    "## Set-up"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:04.978645Z",
     "iopub.status.busy": "2021-04-23T20:42:04.975377Z",
     "iopub.status.idle": "2021-04-23T20:42:07.116655Z",
     "shell.execute_reply": "2021-04-23T20:42:07.115331Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nb-kadrlica-r21-0-0\r\n",
      "lsst_distrib          21.0.0+973e4c9e85 \tcurrent v21_0_0 setup\r\n"
     ]
    }
   ],
   "source": [
    "# What version of the Stack are we using?\n",
    "! echo $HOSTNAME\n",
    "! eups list -s | grep lsst_distrib"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "subslide"
    }
   },
   "source": [
    "You need to be looking at this notebook from within an LSST [JupyterLab](https://jupyterlab.readthedocs.io/en/stable/) instance. If you are, that means you have successfully started a JupyterLab instance, but have also managed to clone the StackClub repo into the `notebooks` folder. If you have not done this yet, please follow the \"Getting Started\" instructions [here](https://github.com/LSSTScienceCollaborations/StackClub/blob/master/GettingStarted.md).\n",
    "\n",
    "Start a terminal via the Launcher (go to the menu on top, \"File\" > \"New Launcher\"), and `cd notebooks/StackClub`. Then, make sure you are in a development branch.  You can make a new one with, for example,\n",
    "\n",
    "```bash \n",
    "git checkout -b issue#11-hello-world-gmm\n",
    "```\n",
    "But of course the argument of this `git checkout -b` command will be different - you can name your local branch whatever you like.\n",
    "\n",
    "> You might need to make sure to check for the existence of the branch.  If you issue the command and the branch exists, you will get a message like \"fatal: A branch named`issue#11_hello-world-gmm` already exists.\" Use `git branch` to see your available local branches, and `git pull` to track all remote branches.\n",
    "\n",
    "> Also please make sure that you are using the correct version of python (\"LSST\");  this might be obvious to some, but editing / running the same notebook with different versions of python can cause problems.  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Editing this Notebook\n",
    "\n",
    "You edit a notebook \"entry by entry\" or more correctly \"cell by cell.\"  To start editing an entry, step to it - a blue bar will appear on the left of the entry.  Cells can be \"Markdown\" (like this one), \"Raw\", or \"Code\" (executable python).\n",
    "\n",
    "The next cell after this one is a python cell, defining a function that you may or may not find useful. When you execute that cell (pro-tip: hit \"shift+enter\"), the function is loaded for later use; the following cell calls that function. Give it a try."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:07.127918Z",
     "iopub.status.busy": "2021-04-23T20:42:07.126528Z",
     "iopub.status.idle": "2021-04-23T20:42:07.130634Z",
     "shell.execute_reply": "2021-04-23T20:42:07.129319Z"
    },
    "slideshow": {
     "slide_type": "-"
    }
   },
   "outputs": [],
   "source": [
    "def take_that_first_baby_step(and_follow_up=''):\n",
    "    \"\"\"\n",
    "    Achieve every programmer's first goal.\n",
    "    \n",
    "    Parameters\n",
    "    ----------\n",
    "    and_follow_up: string, optional\n",
    "        Additional string to print, after the initial announcement.\n",
    "    \n",
    "    Notes\n",
    "    -----\n",
    "    It's always good to write a docstring, especially if its in `numpydoc format <https://numpydoc.readthedocs.io/en/latest/format.html>`_.\n",
    "    \"\"\"\n",
    "    # Just do it:\n",
    "    print(\"Hello World \"+and_follow_up)\n",
    "    \n",
    "    return"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "take_that_first_baby_step()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here is an example task for _real_ newbies:  add a single code or markdown cell at the end of this notebook, with a suitable message for the ages, including some sort of signature. This will make you famous, once you commit and push."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## Contributing Your Work\n",
    "Now that you have improved this Notebook, you need to ask for your work to be included into the Stack Club library of community tutorials. Here's the recommended workflow:\n",
    "\n",
    "1. Check that this notebook runs without errors and clean out the outputs. \n",
    "2. Commit your changes to a development branch\n",
    "3. Push your commits to a branch of the same name to the origin repo at GitHub.com\n",
    "4. On the GitHub web interface, submit a Pull Request to the `master` branch"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### 1. Checking the Notebook\n",
    "\n",
    "From the menu bar, do:\n",
    "```\n",
    "Kernel -> Restart and Run All Cells\n",
    "```\n",
    "Then, if that worked OK, clean up the Notebook with\n",
    "```\n",
    "Kernel -> Restart and Clear All Outputs\n",
    "```\n",
    "The Notebook is now ready to commit.  Hit \"save\" in the notebook editor to make sure your edits are captured.  \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### 2. Committing Your Changes\n",
    "\n",
    "Just in case, make sure you are on a development branch with a `git status` in the terminal tab. \n",
    "If not, make one with something like this:\n",
    "```bash\n",
    "git checkout -b issue#11_Hello_World_gmm\n",
    "```\n",
    "\n",
    "You may not be responding to an issue, so might want to name your branch differently. Here's an example history:\n",
    "```bash\n",
    "[drphilmarshall@jld-lab-drphilmarshall-r150 StackClub]$ git checkout -b issue#11_Hello_World_gmm\n",
    "M       notebooks/Hello_World.ipynb\n",
    "Switched to a new branch 'issue#11_Hello_World_gmm'\n",
    "[drphilmarshall@jld-lab-drphilmarshall-r150 StackClub]$ git status\n",
    "On branch issue#11_Hello_World_gmm\n",
    "Changes not staged for commit:\n",
    "  (use \"git add <file>...\" to update what will be committed)\n",
    "  (use \"git checkout -- <file>...\" to discard changes in working directory)\n",
    "\n",
    "        modified:   notebooks/HelloWorld.ipynb\n",
    "\n",
    "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n",
    "```\n",
    "Now you are ready to commit, like this:\n",
    "```bash\n",
    "[drphilmarshall@jld-lab-drphilmarshall-r150 StackClub]$ git commit -am \"Notes on how to edit the Notebook\"\n",
    "[issue/11/hello-world-pjm 140240c] Notes on how to edit the Notebook\n",
    " 1 file changed, 193 insertions(+), 250 deletions(-)\n",
    " rewrite notebooks/HelloWorld.ipynb (63%)\n",
    "```\n",
    "You might be asked by git to provide info about yourself.  If so, you will need to \n",
    "provide your e-mail address as well as your git username:  you need to provide both.  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### 3. Pushing Your Commits\n",
    "Push to a corresponding branch on GitHub. Stack Club members have Write access to the base repo, so can push there. Others, you'll need to first fork the StackClub repo, and then push to your fork. Here's an example history for an earlier version of a \"HelloWorld\" notebook:\n",
    "```bash\n",
    "[drphilmarshall@jld-lab-drphilmarshall-r150 StackClub]$ git push origin issue/11/hello-world-pjm\n",
    "Counting objects: 4, done.\n",
    "Delta compression using up to 2 threads.\n",
    "Compressing objects: 100% (3/3), done.\n",
    "Writing objects: 100% (4/4), 2.03 KiB | 0 bytes/s, done.\n",
    "Total 4 (delta 1), reused 0 (delta 0)\n",
    "remote: Resolving deltas: 100% (1/1), completed with 1 local object.\n",
    "To github.com:LSSTScienceCollaborations/StackClub.git\n",
    " * [new branch]      issue/11/hello-world-pjm -> issue/11/hello-world-pjm\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### 4. Submitting a Pull Request\n",
    "The `master` branch is protected, to a) make sure we review our code and b) enable continuous integration and testing via travis-ci.\n",
    "\n",
    "> Don't forget, when you click the big green \"Submit Pull Request\" button, it will send an email to everyone watching the repo (as well as anyone else you mention). It's your chance to ask for club code review, so make sure the PR title (email subject line) and comment (email body) are well-formed."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Further Edits to this Notebook\n",
    "\n",
    "Here's where you should make your mark. Have fun!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:07.139876Z",
     "iopub.status.busy": "2021-04-23T20:42:07.138654Z",
     "iopub.status.idle": "2021-04-23T20:42:08.023477Z",
     "shell.execute_reply": "2021-04-23T20:42:08.024597Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Phil was here!\r\n"
     ]
    }
   ],
   "source": [
    "! echo \"Phil was here!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:08.037043Z",
     "iopub.status.busy": "2021-04-23T20:42:08.035812Z",
     "iopub.status.idle": "2021-04-23T20:42:08.860786Z",
     "shell.execute_reply": "2021-04-23T20:42:08.861841Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Alex was here\r\n"
     ]
    }
   ],
   "source": [
    "! echo \"Alex was here\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:08.870859Z",
     "iopub.status.busy": "2021-04-23T20:42:08.869530Z",
     "iopub.status.idle": "2021-04-23T20:42:08.873904Z",
     "shell.execute_reply": "2021-04-23T20:42:08.875009Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Greg was here and edited some more and inserted some questions\n"
     ]
    }
   ],
   "source": [
    "print (\"Greg was here and edited some more and inserted some questions\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:08.882357Z",
     "iopub.status.busy": "2021-04-23T20:42:08.881082Z",
     "iopub.status.idle": "2021-04-23T20:42:08.885162Z",
     "shell.execute_reply": "2021-04-23T20:42:08.886171Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Brant was here, thanks Phil, Alex, and Greg.\n"
     ]
    }
   ],
   "source": [
    "print(\"Brant was here, thanks Phil, Alex, and Greg.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:08.893743Z",
     "iopub.status.busy": "2021-04-23T20:42:08.892590Z",
     "iopub.status.idle": "2021-04-23T20:42:09.788044Z",
     "shell.execute_reply": "2021-04-23T20:42:09.789204Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jeff was here, too.\r\n"
     ]
    }
   ],
   "source": [
    "! echo \"Jeff was here, too.\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:09.798606Z",
     "iopub.status.busy": "2021-04-23T20:42:09.797214Z",
     "iopub.status.idle": "2021-04-23T20:42:09.801669Z",
     "shell.execute_reply": "2021-04-23T20:42:09.802796Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello World it's me, Jeff, using python on the LSP!\n"
     ]
    }
   ],
   "source": [
    "take_that_first_baby_step(and_follow_up=\"it's me, Jeff, using python on the LSP!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:09.809816Z",
     "iopub.status.busy": "2021-04-23T20:42:09.808548Z",
     "iopub.status.idle": "2021-04-23T20:42:09.813062Z",
     "shell.execute_reply": "2021-04-23T20:42:09.814088Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Qingling was here, thanks all!\n"
     ]
    }
   ],
   "source": [
    "print(\"Qingling was here, thanks all!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:09.820634Z",
     "iopub.status.busy": "2021-04-23T20:42:09.819464Z",
     "iopub.status.idle": "2021-04-23T20:42:09.823220Z",
     "shell.execute_reply": "2021-04-23T20:42:09.824161Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Diana was also here!\n"
     ]
    }
   ],
   "source": [
    "print(\"Diana was also here!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:09.830402Z",
     "iopub.status.busy": "2021-04-23T20:42:09.829294Z",
     "iopub.status.idle": "2021-04-23T20:42:09.832871Z",
     "shell.execute_reply": "2021-04-23T20:42:09.833740Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Greg was here again\n"
     ]
    }
   ],
   "source": [
    "print(\"Greg was here again\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:09.839553Z",
     "iopub.status.busy": "2021-04-23T20:42:09.838518Z",
     "iopub.status.idle": "2021-04-23T20:42:09.841959Z",
     "shell.execute_reply": "2021-04-23T20:42:09.842774Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test by Douglas. Hello World!\n"
     ]
    }
   ],
   "source": [
    "print(\"Test by Douglas. Hello World!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-04-23T20:42:09.848242Z",
     "iopub.status.busy": "2021-04-23T20:42:09.847279Z",
     "iopub.status.idle": "2021-04-23T20:42:09.850476Z",
     "shell.execute_reply": "2021-04-23T20:42:09.851287Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test by Sahar. Hello Hello\n"
     ]
    }
   ],
   "source": [
    "print(\"Test by Sahar. Hello Hello\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "LSST",
   "language": "python",
   "name": "lsst"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.8"
  },
  "livereveal": {
   "scroll": true,
   "start_slideshow_at": "selected"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}