diff --git a/01_intro_to_jupyter.ipynb b/01_intro_to_jupyter.ipynb index 1d65c61..bce94f7 100644 --- a/01_intro_to_jupyter.ipynb +++ b/01_intro_to_jupyter.ipynb @@ -27,17 +27,13 @@ "\n", "Jupyter notebooks have two main types of cells: **Markdown** and **Code**.\n", "\n", - "**Markdown** cells allow you to use symbols that are then rendered into nicely formatted text, tables, images, etc. [Markdown](https://en.wikipedia.org/wiki/Markdown) was created in 2004 as a plain text languge for generating formatted text that was itself readable in plain text. It is now widely used across many platforms. While there is a base standard, implementations can differ in some details. The official [Jupyter Notebook markdown](https://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Working%20With%20Markdown%20Cells.html) documentation provides a good overview. You will mostly not need to create markdown for the *Practicum AI* courses, but it will be used to provide the explanatory information for you as you run the code.\n", + "**Markdown** cells allow you to use symbols that are then rendered into nicely formatted text, tables, images, etc. [Markdown](https://en.wikipedia.org/wiki/Markdown) was created in 2004 as a plain text language for generating formatted text that was itself readable in plain text. It is now widely used across many platforms. While there is a base standard, implementations can differ in some details. The official [Jupyter Notebook markdown](https://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Working%20With%20Markdown%20Cells.html) documentation provides a good overview. You will mostly not need to create markdown for the *Practicum AI* courses, but it will be used to provide the explanatory information for you as you run the code.\n", "\n", "### To do\n", "\n", - "* **Double click on this cell to see the raw Markdown text that is rendered to create the formatted text.**\n", - "* **For Jupyter on an HPC cluster**: \n", + "* **Double-click on this cell to see the raw Markdown text that is rendered to create the formatted text.**\n", " * When you are done, either click the play button in the top row, or type Shift-Enter on your keyboard.\n", - " \n", - "* **For Google Colab**:\n", - " * Google Colab has a slightly different Markdown editor view that splits the screen. Markdown is shown on the left, and formatted text on the right. You can even use the text formatting tools on the right to auto-generate the markdown. Rather than using the play button to render Markdown, simply click out of the cell and the split will return to the rendered view.\n", - " " + " \n" ] }, { @@ -47,14 +43,7 @@ "id": "6fd0f4e0-26ef-463c-a341-94b279ca2208" }, "source": [ - "## Now run the code cell below\n", - "\n", - "
Note: For Google Colab: When you run the first cell in a notebook, you will see a warning that the notebook is not authored by Google. You will need to click the Run anyway button to run the notebook.
\n",
- " \n",
- "
\n",
- "
Note: The SSH key generated with this code does not have a passphrase. Adding a passphrase to an SSH key is a best practice. Unfortunately, Jupyter doesn't support them, and you wouldn't be able to use the SSH key with the built in `git` support in Jupyter if we put a passphrase on the key.\n", - "
SSH keys are a more secure method of authenticating a user than usernames and passwords. For this reason, GitHub has stopped using username/password authentication for pushing content to repos.
\n", - " \n", - "SSH is the secure shell application, and how many computers talk to each other. SSH keys consist of two files, one, the private key, should be protected and remain in computers you trust (for example, HiPerGator, or your own computer), the second, the public key, can be placed on any computer you want to login to.
\n", - "\n", - "When you try to login to a computer, like GitHub, messages encrypted and decrypted with the public and private keys are passed between the servers. Only someone in possession of the private key file will be able to login to a server that has had the corresponding public key added to it.
\n", - "\n", - "So, the process of setting up SSH key authentication involves three steps:
\n", - "
As an alternative to the code below, you can also take a step back in time and open a terminal (File menue > New > Terminal) and type the following commands. **You do not need to do both--if you ran the cell above, you can skip to step 2.**\n",
- ">\n",
- ">This is a simplified version of the [details outlined on GitHub.com](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent?platform=linux).\n",
- ">\n",
- ">* First make sure you don't have an existing key file at: `~/.ssh/id_ed25519.pub`:\n",
- "> \n",
- "> `cat ~/.ssh/id_ed25519.pub`\n",
- "> \n",
- "> * That should return an error say that no such file or directory exitsts.\n",
- "> * If it does return \"ssh-ed25519\" followed by a string of letters and numbers, then you can either use that key file, or move/delete the key and its private pair and make a new one.\n",
- ">\n",
- ">* Make the ed25519 key pair with no passphrase:\n",
- ">\n",
- "> `ssh-keygen -t ed25519 -C 'My GitHub key' -N '' -f ~/.ssh/id_ed25519`\n",
- ">\n",
- ">* Display the contents of the public key so you can **copy it**:\n",
- ">\n",
- "> `cat ~/.ssh/id_ed25519.pub`"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "19844553-fc41-4d0a-812c-2a2b56aa31bc",
- "metadata": {},
- "source": [
- "## Step 2: Add your public key to your GitHub account\n",
- "\n",
- "1. Go to your GitHub Settings at: [https://github.com/settings/keys](https://github.com/settings/keys).\n",
- "\n",
- "1. As outlined [on GitHub.com](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account), click the New SSH Key button. [](https://github.com/settings/ssh/new)\n",
- "\n",
- "1. Give the key a name, \"HiPerGator\" for example, and **paste the public key text** you copied above into the Key box.\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "9c9e3929-cc83-43c7-8733-0e74d94ed9ac",
- "metadata": {},
- "source": [
- "## Step 3: Configure `git` on HiPerGator for your user\n",
- "\n",
- "The following code cell will ask you to enter your name and then your email. It will then setup git on HiPerGator using the values you provide. Run this cell unchanged and enter the information in the propt box. "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "948b70f8-1117-4f82-84c8-e2a1c739890b",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Do not change this code block\n",
- "\n",
- "# Ask user for their name and email\n",
- "name = input(\"Please enter your name:\")\n",
- "email = input(\"Please enter your email:\")\n",
- "\n",
- "print(f\"Thank you {name}, now configuring your git account with your name and email\")\n",
- "\n",
- "# Run git config to set user.name and user.email\n",
- "os.system(f\"git config --global user.name '{name}'\")\n",
- "os.system(f\"git config --global user.email {email}\")\n",
- "\n",
- "print(f\"\\nVerifying the configuration has been set.\")\n",
- "\n",
- "# Get current git config list and use grep to show only the user lines\n",
- "config_list = os.system(\"git config --list | grep user\")\n",
- "\n",
- "print(f\"\\nAssuming user.name and user.email look correct, you should be set.\")\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "ccab460c-2edb-4b15-a021-f344474465ae",
- "metadata": {},
- "source": [
- "### Alternative Bash Command Line Method\n",
- "\n",
- "**You do not need to do this if you ran the cell above. This is an alternative method to do the step.**\n",
- "\n",
- ">\n",
- ">Run the following 2 commands using your Name (inside quotes) and email address:\n",
- ">\n",
- "> `git config --global user.name 'Your Name'`\n",
- "> \n",
- "> `git config --global user.email your_email@example.com`\n",
- "> \n",
- ">The lines configure git for your user account."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4fce5a7f-c94a-4072-b67f-ba7ffea14102",
- "metadata": {
- "tags": []
- },
- "source": [
- "## Step 4: Test your SSH key\n",
- "\n",
- "**IMPORTANT: Do not skip this step** Test the key and add github.com to your known hosts. Back in the Jupyter terminal, type:\n",
- "\n",
- "The cell below adds the known information about the GitHub server to your known_hosts file (located at `~/.ssh/known_hosts`) and tests the connection to GitHub. \n",
- "\n",
- "You may see a warning about permenantly adding the ECDSA host key for an IP address. This is Ok.\n",
- "You should then see a greating from GitHub with your GitHub username. It will say \"You've successfully authenticated, but GitHub does not provide shell access.\" That is the expected output and means everything is setup correctly!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "966f1bb9-5d3d-4e45-84bb-cec41becc828",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Do not change this code block\n",
- "\n",
- "# Add github host information to known hosts file.\n",
- "!echo 'github.com,140.82.112.3 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=' \\\n",
- " >> ~/.ssh/known_hosts\n",
- "\n",
- "# Test ssh connection to GitHub using the SSH keys setup above.\n",
- "!ssh -T git@github.com\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2ac625b6-af75-4c20-8dfc-9df281d2b90b",
- "metadata": {
- "tags": []
- },
- "source": [
- "### Alternative Bash Command Line Method\n",
- "\n",
- "**You do not need to do this if you ran the cell above. This is an alternative method to do the step.**\n",
- "\n",
- ">* As [outlined on GitHub.com](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection): In the terminal type:\n",
- ">\n",
- "> `ssh -T git@github.com`\n",
- ">\n",
- "> (Do NOT replace the username, type it as git@github.com). \n",
- "> \n",
- "> * Since this is likely the first time you have connected to github.com from the compute your are on, you will be asked if you want to trust the unknown host. Type: **`yes`** \n",
- "> * You should then see a reply like this:\n",
- ">\n",
- "> ```\n",
- "> [magitz@login6 ~]$ ssh -T git@github.com\n",
- "> Hi magitz! You've successfully authenticated, but GitHub does not provide shell access.\n",
- "> ```\n",
- ">\n",
- "> * This is the expected reply, your GitHub.com user name will be shown along with a note that you have successfully authenticated (using the setup ssh keys), but that GitHub does not provide shell access."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "0d4ad84b-ebc0-426e-81a4-081b7d02b316",
- "metadata": {},
- "source": [
- "## Step 5: Creat symbolic links to your `/blue` directory\n",
- "\n",
- "On HiPerGator, each user has a home directory (located at `/home/username`), which is where Jupyter starts and is likely where you are now, and one or more directories on the `/blue` filesystem (our high-performance filesystem). UFIT Research Computing policy is that all data read or written while running applications should be on the `/blue` filesystem, not in `/home/`. \n",
- "\n",
- "Unfortunately, Jupyter doesn't have an easy way to navigate to your `blue` directories. This cell will check the group used when you submitted the job, and make a symbolic link to the `/blue/group` directory, calling it `blue_group`. This will then appear as folders in your home directory."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "d8a92986-40ff-4c7c-ba69-6e671a21cbb7",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Do not change this code block\n",
- "\n",
- "# Get the group used to submit the job running this notebook and user's home directory\n",
- "group = os.getenv(\"SLURM_JOB_ACCOUNT\")\n",
- "home = os.getenv(\"HOME\")\n",
- "\n",
- "# Set filesystem to make link to: 'blue' on HiPerGator\n",
- "filesystem = 'blue'\n",
- "\n",
- "# Get path to link to: /blue/group on HiPerGator and set a name for the link, blue_group by convention\n",
- "link_path = os.path.join(os.sep, filesystem, group)\n",
- "link_name = filesystem + '_' + group\n",
- "\n",
- "if os.path.islink(os.path.join(os.sep, home, link_name)) or os.path.isfile(os.path.join(os.sep, home, link_name)):\n",
- " print(f\"Symbolic link, or file, already exists at {os.path.join(os.sep, home, link_name)}, doing nothing.\")\n",
- "else:\n",
- " print(f\"Making symbolic link to {link_path} at {os.path.join(os.sep, home, link_name)}\")\n",
- " os.system(f\"ln -s {link_path} {os.path.join(os.sep, home, link_name)}\") \n",
- "\n",
- "print(\"\\nDone!\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "4c8032e6-faed-4abe-a1b1-57da4f9dc197",
- "metadata": {},
- "source": [
- "### Alternative Bash Command Line Method\n",
- "\n",
- "**You do not need to do this if you ran the cell above. This is an alternative method to do the step.**\n",
- "\n",
- ">First, determine the group where your `/blue` folder is located. The `id` command will show all your groups. For example:\n",
- ">\n",
- ">```bash\n",
- ">[albert@c1000a-s29 ~]$ id\n",
- ">uid=91234(albert) gid=9000(gator) groups=9000(gator),7917(practicum-ai)\n",
- ">```\n",
- ">\n",
- ">This shows that the user albert has the primary group of \"gator\" and is also in the \"practicum-ai\" group. They should most likely use the \"gator\" group for the next step.\n",
- ">\n",
- ">Second, create the link to `/blue/group` in your home directory. For the user albert above, making a link to the group gator, they would type:\n",
- ">\n",
- ">```ln -s /blue/gator ~/blue_gator```\n",
- ">\n",
- ">**Note**: You need to replace \"gator\" with **your** group name! The `ln -s` part of the command is to create a symbolic link, the `/blue/gator` part is what you want to link to (and why you need to change that so that the link points to your group directory), and the `~/blue_gator` is what you want to name the link (`~` is short for your home directory). We use the `blue_group` convention, because that makes it clear where the link is going to take you."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "f161a0d7-ed0e-4655-8a70-3675bdc5181c",
- "metadata": {},
- "source": [
- "## That's it!!\n",
- "\n",
- "Your account should be setup and ready to go!"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "260b8356-90d5-4c7f-9a8f-5318adf86e97",
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "UFRC Python-3.10",
- "language": "python",
- "name": "python3-3.10-ufrc"
- },
- "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.10.8"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/README.md b/README.md
index a5b7d6b..887f05a 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,17 @@
-# Computing for AI: A Practicum AI Workshop
+# Computing for AI: A Practicum AI Course (USDA-ARS Version)
-