diff --git a/HowTos/ShareNotebooks/3-ShareNotebooks-ShareURL.ipynb b/HowTos/ShareNotebooks/3-ShareNotebooks-ShareURL.ipynb index d7a2322..c10be04 100644 --- a/HowTos/ShareNotebooks/3-ShareNotebooks-ShareURL.ipynb +++ b/HowTos/ShareNotebooks/3-ShareNotebooks-ShareURL.ipynb @@ -1,227 +1,236 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "

How to share notebooks with students?

\n", "

Table of contents

\n", "
    \n", "
  1. Create a git repository on c4science
  2. \n", "
  3. Access your repository from Noto
  4. \n", "
  5. Share the repository with students on Noto
  6. \n", "
\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 3. Share the repository with students on Noto\n", "\n", "In the following, you will learn how to **generate a simple URL link** that you can share with your students so that they are able to **view and execute your notebooks on Noto**.
\n", "\n", "
\n", "\n", "
\n", " \n", "The method we describe in this tutorial works with anyone being able to log on Noto, i.e. all EPFL members and all members of universities with [Switch-AAI authentication](https://www.switch.ch/aai/participants/homeorgs/) (e.g. UNIL, ETHZ, UniGE, HEP-VD, etc.).

\n", "If you want to share your notebooks with people **outside of these organizations**, you should look for alternative ways of sharing such as with [MyBinder](https://mybinder.org/) for instance. \n", " \n", "
\n", "\n", "
\n", "\n", "The method we describe in this tutorial uses a tool called `nbgitpuller` which generates shareable URL links for `git` repositories. \n", "**If your notebooks are not already stored in a `git` repository**, please check [step 1 of this tutorial](1-ShareNotebooks-CreateGitRepo.ipynb). \n", "\n", "When clicked, a `nbgitpuller` link will automatically do the following for your students:\n", "* **Launch Noto** and open their personal workspace\n", "* **Clone your `git` repository** (or pull it if they have already clicked on the link previously) in their personal workspace\n", "* **Open a notebook** of your choice\n", "\n", "In that way, they can very simply access the notebooks from your `git` repository *without needing to know anything about `git`*." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3.a. Check access rights on your git repository\n", "\n", "Before going any further, you should check that your git repository has **public reading access**.
\n", "If you have followed the indications from [step 1 of this tutorial](1-ShareNotebooks-CreateGitRepo.ipynb) on how to create your repository on [c4science](https://c4science.ch) this should already be the case. \n", "Otherwise, we advise you to set the access rights accordingly." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3.b. Create a shareable link\n", "\n", "We provide you with a script to generate a `nbgitpuller` link automatically. \n", "You need to **specify the following two parameters**:\n", "1. The HTTPS URL of your git repository, *without the '.git' extension*.
\n", " If you need help to find this URL, see [this section below](#Appendix:-Find-the-HTTPS-URL-of-a-git-repository-on-c4science).
\n", " For instance, the URL of the git repository containing this notebook is: `https://c4science.ch/source/noto-poc-notebooks`
\n", "
\n", "1. The path to the notebook you want to open when the link is clicked.
\n", " This path describes where the notebook is inside the git repository. \n", " For instance, the path to this notebook is: `HowTos/ShareNotebooks/3-ShareNotebooks-ShareURL.ipynb`\n", "\n", "**Change those two parameters in the code cell below**, then execute it. Of course if you need to change other parameters, feel free to do so (see the [nbgitpuller documentation](https://jupyterhub.github.io/nbgitpuller/link?hub=https://noto.epfl.ch)). \n", - "The resulting link will be displayed in bold green just below." + "The resulting link will be displayed in the output just below." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Your nbgitpuller link is:\n", + "https://noto.epfl.ch/hub/user-redirect/git-pull?repo=https%3A%2F%2Fc4science.ch%2Fsource%2Fnoto-poc-notebooks&urlpath=lab%2Ftree%2Fnoto-poc-notebooks%2FHowTos%2FShareNotebooks%2F0-ShareNotebooks-TableOfContents.ipynb%3Fautodecode&branch=master\n" + ] + } + ], "source": [ "# PARAMETERS TO CHANGE:\n", "git_https_url = \"https://c4science.ch/source/noto-poc-notebooks\"\n", "path_to_notebook = \"HowTos/ShareNotebooks/0-ShareNotebooks-TableOfContents.ipynb\"\n", "\n", "\n", "# Creation of the link\n", "from nbgitpuller_link import Link\n", "linker = Link(\n", " jupyterhub_url = \"https://noto.epfl.ch\",\n", " branch = \"master\",\n", " interface = \"lab\",\n", " repository_url = git_https_url,\n", " launch_path = path_to_notebook,\n", " )\n", "\n", "# Display of the link\n", - "print(\"Your nbgitpuller link is:\\n\\033[1m\\x1b[32m{}\\x1b[0m\\033[0m\".format(linker.link))" + "print(f\"Your nbgitpuller link is:\\n{linker.link}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", - "The resulting link, displayed in bold green just above, should be similar to: \n", + "The resulting link, displayed in the output just above, should be similar to: \n", "`https://noto.epfl.ch/hub/user-redirect/git-pull?repo=https%3A%2F%2Fc4science.ch%2Fsource%2Fnoto-poc-notebooks&urlpath=lab%2Ftree%2Fnoto-poc-notebooks%2FHowTos%2FShareNotebooks%2F3-ShareNotebooks-ShareURL.ipynb%3Fautodecode&branch=master`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Choose the `depth` of cloning (optional)\n", "\n", "By default, the entire history of the git repository is pulled in the user's workspace. This might be slow if your git repository is large or if a large number of students are going to pull at the same time. You can set this to pull only the latest commit on initial pull, just by adding `&depth=1` at the end of the URL:\n", "\n", "`https://noto.epfl.ch/hub/user-redirect/git-pull?repo=https%3A%2F%2Fc4science.ch%2Fsource%2Fnoto-poc-notebooks&urlpath=lab%2Ftree%2Fnoto-poc-notebooks%2FHowTos%2FShareNotebooks%2F3-ShareNotebooks-ShareURL.ipynb%3Fautodecode&branch=master&depth=1`\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3.c. Test the link\n", "\n", "**Before sharing the link with your students it is important that you test it!**
\n", "By pasting the link in your web browser, you should first see a page like the one in the screen capture below, and then you should get sent to the desired notebook.\n", "\n", "\n", "\n", "Note that if you already have an opened Noto session in your browser, jupyterlab will create a new session automatically.\n", "\n", "**/!\\ Watch out:** After testing the link, you will have a second copy of your repository in your Noto workspace, and this copy will be read-only. So you might want to delete this new copy right away to avoid problems." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3.d. Shorten the link (optional)\n", "\n", "Once you are happy and ready to share your link, you can make it shorter and prettier by using a URL shortening service such as [go.epfl.ch](https://go.epfl.ch). \n", "\n", "For instance, [`go.epfl.ch/noto-share`](https://go.epfl.ch/noto-share) is a pretty link to this notebook based on the URL we have generated in the previous section.\n", "\n", "Using `go.epfl.ch`, you can create there short and nice looking links that you will be able to distribute by email, your Moodle page, etc. \n", "It is also worth noting that you will get (basic but useful) statistics on your URLs, which is nice!\n", "\n", "
\n", "\n", "**You're done!** Now you can create as many links as you want to share notebooks from your `git` repository with students. \n", "Each time they will click a link directing them to your repository, `nbgitpuller` will pull the latest version of the content from your `git` server.\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", " <<< 2. Access your repository from Noto\n", "    |   \n", " 3. Share the repository with students on Noto\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "# Appendix: Find the HTTPS URL of a git repository on c4science" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "To get the HTTPS URL of your git repository on c4science, first find the page displaying the current content of your repository (for instance, go back to the welcome page of c4science, then go to the `Applications > Repositories` menu on the left pane, find your repository in the list and click on it). \n", "\n", "Then click on the `Clone` button.\n", "\n", "\n", "\n", "In the form which appears, **copy the first URL** (the one starting with `https://...`) **without the `.git` at the end**.\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { - "display_name": "nbgitpullerenv", + "display_name": "Python", "language": "python", - "name": "nbgitpullerenv" + "name": "python3" }, "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.6.9" + "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 4 }