From 056a0f9f1c1bfdd5226d201170ac87185313c88a Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sat, 7 Jan 2023 23:20:04 +0000 Subject: [PATCH 01/15] initial binder example --- notebooks/example/README.md | 6 ++ notebooks/example/example.ipynb | 119 +++++++++++++++++++++++++++++ notebooks/example/requirements.txt | 1 + 3 files changed, 126 insertions(+) create mode 100644 notebooks/example/README.md create mode 100644 notebooks/example/example.ipynb create mode 100644 notebooks/example/requirements.txt diff --git a/notebooks/example/README.md b/notebooks/example/README.md new file mode 100644 index 00000000..e847d343 --- /dev/null +++ b/notebooks/example/README.md @@ -0,0 +1,6 @@ +# Example Notebook + +[![Binder](http://mybinder.org/badge_logo.svg)](http://mybinder.org/v2/gh/andrewm4894/Open-Assistant/blob/example-notebook/notebooks/example/) + +This folder contains an example reference notebook structure and approach for +this project. Please try and follow this structure as closely as possible. diff --git a/notebooks/example/example.ipynb b/notebooks/example/example.ipynb new file mode 100644 index 00000000..ff0472b3 --- /dev/null +++ b/notebooks/example/example.ipynb @@ -0,0 +1,119 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/andrewm4894/Open-Assistant/blob/example-notebook/notebooks/example/example.ipynb)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# uncomment below cell to install required packages if running in Google Colab.\n", + "#!pip install transformers" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example Notebook" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Try to add a markdown section to the notebook that explains what the notebook is about and what it does. This will help people understand what the notebook is for and how to use it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# import required packages\n", + "from transformers import pipeline" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Use Headings\n", + "\n", + "(it will help with link sharing to specific sections of the notebook)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Make fancy markdown cells if you want." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "# Do cool stuff here" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Binder" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We want to have every notebook folder be easily runnable on Binder. This means that every notebook folder should have a `requirements.txt` file that contains all the dependencies for the notebook. This is so that Binder can install all the dependencies for the notebook when it is run.\n", + "\n", + "If you have more complex dependencies then there are a number of ways to add additional configuration files in the folder that Binder will use to install the dependencies. See the [Binder documentation](https://mybinder.readthedocs.io/en/latest/config_files.html) for more information." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "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.10.4" + }, + "orig_nbformat": 4, + "vscode": { + "interpreter": { + "hash": "3ad933181bd8a04b432d3370b9dc3b0662ad032c4dfaa4e4f1596c548f763858" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/notebooks/example/requirements.txt b/notebooks/example/requirements.txt new file mode 100644 index 00000000..976a2b1f --- /dev/null +++ b/notebooks/example/requirements.txt @@ -0,0 +1 @@ +transformers From 834d393950d26730b2d5613c37b8d9e6c2d04cec Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sat, 7 Jan 2023 23:43:57 +0000 Subject: [PATCH 02/15] dev --- notebooks/example/README.md | 2 +- notebooks/example/example.ipynb | 59 +++++++++++++++++++++++++++--- notebooks/example/requirements.txt | 1 - 3 files changed, 54 insertions(+), 8 deletions(-) delete mode 100644 notebooks/example/requirements.txt diff --git a/notebooks/example/README.md b/notebooks/example/README.md index e847d343..b2d2eb22 100644 --- a/notebooks/example/README.md +++ b/notebooks/example/README.md @@ -1,6 +1,6 @@ # Example Notebook -[![Binder](http://mybinder.org/badge_logo.svg)](http://mybinder.org/v2/gh/andrewm4894/Open-Assistant/blob/example-notebook/notebooks/example/) +[![Binder](http://mybinder.org/badge_logo.svg)](http://mybinder.org/v2/gh/andrewm4894/Open-Assistant/example-notebook?urlpath=/notebooks/example/example.ipynb) This folder contains an example reference notebook structure and approach for this project. Please try and follow this structure as closely as possible. diff --git a/notebooks/example/example.ipynb b/notebooks/example/example.ipynb index ff0472b3..de199a60 100644 --- a/notebooks/example/example.ipynb +++ b/notebooks/example/example.ipynb @@ -9,12 +9,50 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting transformers\n", + " Downloading transformers-4.25.1-py3-none-any.whl (5.8 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.8/5.8 MB\u001b[0m \u001b[31m51.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n", + "\u001b[?25hCollecting huggingface-hub<1.0,>=0.10.0\n", + " Downloading huggingface_hub-0.11.1-py3-none-any.whl (182 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m182.4/182.4 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: packaging>=20.0 in /home/codespace/.local/lib/python3.10/site-packages (from transformers) (22.0)\n", + "Collecting regex!=2019.12.17\n", + " Downloading regex-2022.10.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (770 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m770.5/770.5 kB\u001b[0m \u001b[31m29.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting tokenizers!=0.11.3,<0.14,>=0.11.1\n", + " Downloading tokenizers-0.13.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.6 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.6/7.6 MB\u001b[0m \u001b[31m65.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m\n", + "\u001b[?25hCollecting filelock\n", + " Downloading filelock-3.9.0-py3-none-any.whl (9.7 kB)\n", + "Collecting tqdm>=4.27\n", + " Downloading tqdm-4.64.1-py2.py3-none-any.whl (78 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m78.5/78.5 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: pyyaml>=5.1 in /home/codespace/.local/lib/python3.10/site-packages (from transformers) (6.0)\n", + "Requirement already satisfied: numpy>=1.17 in /home/codespace/.local/lib/python3.10/site-packages (from transformers) (1.24.0)\n", + "Requirement already satisfied: requests in /home/codespace/.local/lib/python3.10/site-packages (from transformers) (2.28.1)\n", + "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/codespace/.local/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.10.0->transformers) (4.4.0)\n", + "Requirement already satisfied: charset-normalizer<3,>=2 in /home/codespace/.local/lib/python3.10/site-packages (from requests->transformers) (2.1.1)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/codespace/.local/lib/python3.10/site-packages (from requests->transformers) (3.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/codespace/.local/lib/python3.10/site-packages (from requests->transformers) (2022.12.7)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/codespace/.local/lib/python3.10/site-packages (from requests->transformers) (1.26.13)\n", + "Installing collected packages: tokenizers, tqdm, regex, filelock, huggingface-hub, transformers\n", + "Successfully installed filelock-3.9.0 huggingface-hub-0.11.1 regex-2022.10.31 tokenizers-0.13.2 tqdm-4.64.1 transformers-4.25.1\n" + ] + } + ], "source": [ "# uncomment below cell to install required packages if running in Google Colab.\n", - "#!pip install transformers" + "!pip install transformers\n", + "# if needed you can git clone the repo\n", + "!git clone https://github.com/andrewm4894/Open-Assistant.git\n", + "!cd Open-Assistant/notebooks/example" ] }, { @@ -35,9 +73,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/codespace/.python/current/lib/python3.10/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + } + ], "source": [ "# import required packages\n", "from transformers import pipeline" @@ -63,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ diff --git a/notebooks/example/requirements.txt b/notebooks/example/requirements.txt deleted file mode 100644 index 976a2b1f..00000000 --- a/notebooks/example/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -transformers From 04c7ea031f7c6cb23b3fec7c0a801d7da36e6fa6 Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:06:17 +0000 Subject: [PATCH 03/15] dev --- notebooks/example/data/data.csv | 3 +++ notebooks/example/example.ipynb | 33 ++++++++---------------------- notebooks/example/requirements.txt | 1 + 3 files changed, 13 insertions(+), 24 deletions(-) create mode 100644 notebooks/example/data/data.csv create mode 100644 notebooks/example/requirements.txt diff --git a/notebooks/example/data/data.csv b/notebooks/example/data/data.csv new file mode 100644 index 00000000..126a03bb --- /dev/null +++ b/notebooks/example/data/data.csv @@ -0,0 +1,3 @@ +row,text,label +1,some example data,1 +2,some more data,0 diff --git a/notebooks/example/example.ipynb b/notebooks/example/example.ipynb index de199a60..0d8e1fcb 100644 --- a/notebooks/example/example.ipynb +++ b/notebooks/example/example.ipynb @@ -48,11 +48,12 @@ } ], "source": [ - "# uncomment below cell to install required packages if running in Google Colab.\n", - "!pip install transformers\n", - "# if needed you can git clone the repo\n", - "!git clone https://github.com/andrewm4894/Open-Assistant.git\n", - "!cd Open-Assistant/notebooks/example" + "# uncomment and run below lines to set up if running in colab\n", + "#%%bash\n", + "# git clone https://github.com/andrewm4894/Open-Assistant.git\n", + "# git checkout example-notebook\n", + "# cd Open-Assistant/notebooks/example\n", + "# pip install -r requirements.txt" ] }, { @@ -87,6 +88,7 @@ ], "source": [ "# import required packages\n", + "import pandas as pd\n", "from transformers import pipeline" ] }, @@ -114,25 +116,8 @@ "metadata": {}, "outputs": [], "source": [ - "# Do cool stuff here" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Binder" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We want to have every notebook folder be easily runnable on Binder. This means that every notebook folder should have a `requirements.txt` file that contains all the dependencies for the notebook. This is so that Binder can install all the dependencies for the notebook when it is run.\n", - "\n", - "If you have more complex dependencies then there are a number of ways to add additional configuration files in the folder that Binder will use to install the dependencies. See the [Binder documentation](https://mybinder.readthedocs.io/en/latest/config_files.html) for more information." + "# Do cool stuff here\n", + "df = pd.read_csv(\"data/data.csv\")" ] } ], diff --git a/notebooks/example/requirements.txt b/notebooks/example/requirements.txt new file mode 100644 index 00000000..976a2b1f --- /dev/null +++ b/notebooks/example/requirements.txt @@ -0,0 +1 @@ +transformers From 4953c698aec23df078470d138c107d2cee0874ac Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:09:13 +0000 Subject: [PATCH 04/15] dev --- notebooks/example/example.ipynb | 122 +++++++++++++++++--------------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/notebooks/example/example.ipynb b/notebooks/example/example.ipynb index 0d8e1fcb..d65c2e51 100644 --- a/notebooks/example/example.ipynb +++ b/notebooks/example/example.ipynb @@ -9,51 +9,15 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Collecting transformers\n", - " Downloading transformers-4.25.1-py3-none-any.whl (5.8 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.8/5.8 MB\u001b[0m \u001b[31m51.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n", - "\u001b[?25hCollecting huggingface-hub<1.0,>=0.10.0\n", - " Downloading huggingface_hub-0.11.1-py3-none-any.whl (182 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m182.4/182.4 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: packaging>=20.0 in /home/codespace/.local/lib/python3.10/site-packages (from transformers) (22.0)\n", - "Collecting regex!=2019.12.17\n", - " Downloading regex-2022.10.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (770 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m770.5/770.5 kB\u001b[0m \u001b[31m29.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting tokenizers!=0.11.3,<0.14,>=0.11.1\n", - " Downloading tokenizers-0.13.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.6 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.6/7.6 MB\u001b[0m \u001b[31m65.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m\n", - "\u001b[?25hCollecting filelock\n", - " Downloading filelock-3.9.0-py3-none-any.whl (9.7 kB)\n", - "Collecting tqdm>=4.27\n", - " Downloading tqdm-4.64.1-py2.py3-none-any.whl (78 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m78.5/78.5 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: pyyaml>=5.1 in /home/codespace/.local/lib/python3.10/site-packages (from transformers) (6.0)\n", - "Requirement already satisfied: numpy>=1.17 in /home/codespace/.local/lib/python3.10/site-packages (from transformers) (1.24.0)\n", - "Requirement already satisfied: requests in /home/codespace/.local/lib/python3.10/site-packages (from transformers) (2.28.1)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/codespace/.local/lib/python3.10/site-packages (from huggingface-hub<1.0,>=0.10.0->transformers) (4.4.0)\n", - "Requirement already satisfied: charset-normalizer<3,>=2 in /home/codespace/.local/lib/python3.10/site-packages (from requests->transformers) (2.1.1)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/codespace/.local/lib/python3.10/site-packages (from requests->transformers) (3.4)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/codespace/.local/lib/python3.10/site-packages (from requests->transformers) (2022.12.7)\n", - "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/codespace/.local/lib/python3.10/site-packages (from requests->transformers) (1.26.13)\n", - "Installing collected packages: tokenizers, tqdm, regex, filelock, huggingface-hub, transformers\n", - "Successfully installed filelock-3.9.0 huggingface-hub-0.11.1 regex-2022.10.31 tokenizers-0.13.2 tqdm-4.64.1 transformers-4.25.1\n" - ] - } - ], + "outputs": [], "source": [ "# uncomment and run below lines to set up if running in colab\n", - "#%%bash\n", - "# git clone https://github.com/andrewm4894/Open-Assistant.git\n", - "# git checkout example-notebook\n", - "# cd Open-Assistant/notebooks/example\n", - "# pip install -r requirements.txt" + "# !git clone https://github.com/andrewm4894/Open-Assistant.git\n", + "# !git checkout example-notebook\n", + "# %cd Open-Assistant/notebooks/example\n", + "# !pip install -r requirements.txt" ] }, { @@ -74,18 +38,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/codespace/.python/current/lib/python3.10/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", - " from .autonotebook import tqdm as notebook_tqdm\n" - ] - } - ], + "outputs": [], "source": [ "# import required packages\n", "import pandas as pd\n", @@ -112,12 +67,67 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
rowtextlabel
01some example data1
12some more data0
\n", + "
" + ], + "text/plain": [ + " row text label\n", + "0 1 some example data 1\n", + "1 2 some more data 0" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Do cool stuff here\n", - "df = pd.read_csv(\"data/data.csv\")" + "df = pd.read_csv(\"data/data.csv\")\n", + "df.head()" ] } ], From 8a1b1e46e75e0a6b421bbd6b0b3918b60070078f Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:09:50 +0000 Subject: [PATCH 05/15] dev --- notebooks/example/example.ipynb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/notebooks/example/example.ipynb b/notebooks/example/example.ipynb index d65c2e51..dab70cb8 100644 --- a/notebooks/example/example.ipynb +++ b/notebooks/example/example.ipynb @@ -14,8 +14,7 @@ "outputs": [], "source": [ "# uncomment and run below lines to set up if running in colab\n", - "# !git clone https://github.com/andrewm4894/Open-Assistant.git\n", - "# !git checkout example-notebook\n", + "# !git clone https://github.com/andrewm4894/Open-Assistant.git && git checkout example-notebook\n", "# %cd Open-Assistant/notebooks/example\n", "# !pip install -r requirements.txt" ] From 4e9bedca4b7c022d9c7c9abbb34291c962dd27fe Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:13:35 +0000 Subject: [PATCH 06/15] dev --- notebooks/example/example.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notebooks/example/example.ipynb b/notebooks/example/example.ipynb index dab70cb8..88796e0a 100644 --- a/notebooks/example/example.ipynb +++ b/notebooks/example/example.ipynb @@ -14,7 +14,8 @@ "outputs": [], "source": [ "# uncomment and run below lines to set up if running in colab\n", - "# !git clone https://github.com/andrewm4894/Open-Assistant.git && git checkout example-notebook\n", + "# !git clone https://github.com/andrewm4894/Open-Assistant.git\n", + "# %cd Open-Assistant && git checkout example-notebook\n", "# %cd Open-Assistant/notebooks/example\n", "# !pip install -r requirements.txt" ] From 11f52d8d584b85933d4f2edde59f7c5a4178164f Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:15:29 +0000 Subject: [PATCH 07/15] dev --- notebooks/example/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/example/README.md b/notebooks/example/README.md index b2d2eb22..f33af8fc 100644 --- a/notebooks/example/README.md +++ b/notebooks/example/README.md @@ -1,6 +1,6 @@ # Example Notebook -[![Binder](http://mybinder.org/badge_logo.svg)](http://mybinder.org/v2/gh/andrewm4894/Open-Assistant/example-notebook?urlpath=/notebooks/example/example.ipynb) +[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/andrewm4894/Open-Assistant/blob/example-notebook/notebooks/example/example.ipynb) This folder contains an example reference notebook structure and approach for this project. Please try and follow this structure as closely as possible. From ff399ef87517b9d1d33aa1f184f80c37d4638a7d Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:21:36 +0000 Subject: [PATCH 08/15] dev --- notebooks/example/example.ipynb | 1 - 1 file changed, 1 deletion(-) diff --git a/notebooks/example/example.ipynb b/notebooks/example/example.ipynb index 88796e0a..c9b873aa 100644 --- a/notebooks/example/example.ipynb +++ b/notebooks/example/example.ipynb @@ -15,7 +15,6 @@ "source": [ "# uncomment and run below lines to set up if running in colab\n", "# !git clone https://github.com/andrewm4894/Open-Assistant.git\n", - "# %cd Open-Assistant && git checkout example-notebook\n", "# %cd Open-Assistant/notebooks/example\n", "# !pip install -r requirements.txt" ] From 55cb144471155cb1edcc8e065576291d06616bf4 Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:47:14 +0000 Subject: [PATCH 09/15] dev --- notebooks/README.md | 6 +++++- notebooks/example/README.md | 41 +++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/notebooks/README.md b/notebooks/README.md index edb5da33..fbe3a193 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -1,10 +1,14 @@ # Notebooks This is a folders with some useful notebooks, all the notebooks have a markdown -file with the same name explaining what they do. +file with the same name explaining what they do (or a README.md if its a single +notebook folder). ## Contributing Contributing to both notebooks and making new notebooks is very welcome. If you do so, make sure to make a markdown (.md) file to go with your notebook, makes it easier for people to know what your notebook is about. + +Check out the [example notebook](example/) for a reference example you can use +as a starting point. diff --git a/notebooks/example/README.md b/notebooks/example/README.md index f33af8fc..b975254a 100644 --- a/notebooks/example/README.md +++ b/notebooks/example/README.md @@ -1,6 +1,43 @@ # Example Notebook -[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/andrewm4894/Open-Assistant/blob/example-notebook/notebooks/example/example.ipynb) +[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/andrewm4894/Open-Assistant/blob/main/notebooks/example/example.ipynb) This folder contains an example reference notebook structure and approach for -this project. Please try and follow this structure as closely as possible. +this project. Please try and follow this structure as closely as possible. While +things will not exactly be the same for each notebook some principles we would +like to try ensure are: + +1. Each notebook or collection of related or dependant notebooks should live in + its own folder. +1. Each notebook should have a markdown file with the same name as the notebook + (or README.md if it's a single notebook folder) that explains what the + notebook does and how to use it. +1. Add an "Open in Colab" badge to the top of the notebook. +1. Make it as easy as possible for someone to run the notebook in Google Colab + or some other environment based on standard practices like providing a + `requirements.txt` file or anything else needed to successfully run the + notebook. + +## Running in Google Colab + +At the top of the notebook there is a code cell that will (once uncommented): + +1. clone the repository into your colab instance. +1. `cd` into the relevant notebook directory. +1. run `pip install -r requirements.txt` to install the required packages. + +At this point you can run the notebook as normal and the folder structure will +match that of the repository and the colab notebook will be running from the +same directory that the notebook lives in so relative links etc should work as +expected (for example `example.ipynb` will read some sample data from +`data/data.csv`). + +If you are adding a notebook please try and add a similar cell to the top of the +notebook so that it is easy for others to run the notebook in colab. + +## example.ipynb + +This notebook contains an example "Open In Colab" badge and a code cell to +prepare the colab environment to run the notebook. It also contains a code cell +that will read in some sample data from the `data` folder in the repository and +display it as a pandas dataframe. From bb469b9cd7fea873600fda91b04306c295d24f4f Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:51:50 +0000 Subject: [PATCH 10/15] dev --- notebooks/example/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notebooks/example/README.md b/notebooks/example/README.md index b975254a..e3af2b7b 100644 --- a/notebooks/example/README.md +++ b/notebooks/example/README.md @@ -20,7 +20,8 @@ like to try ensure are: ## Running in Google Colab -At the top of the notebook there is a code cell that will (once uncommented): +At the top of the [example notebook](example.ipynb) there is a code cell that +will (once uncommented): 1. clone the repository into your colab instance. 1. `cd` into the relevant notebook directory. From bc365cb46fd65519ac1e4b9131c8514e11f8baa6 Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 00:59:18 +0000 Subject: [PATCH 11/15] dev --- notebooks/example/README.md | 8 ++++++-- notebooks/example/example.ipynb | 16 ++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/notebooks/example/README.md b/notebooks/example/README.md index e3af2b7b..2136834d 100644 --- a/notebooks/example/README.md +++ b/notebooks/example/README.md @@ -12,7 +12,8 @@ like to try ensure are: 1. Each notebook should have a markdown file with the same name as the notebook (or README.md if it's a single notebook folder) that explains what the notebook does and how to use it. -1. Add an "Open in Colab" badge to the top of the notebook. +1. Add an "Open in Colab" badge to the top of the notebook (see the markdown + cell near the top of `example.ipynb` as an example you can adapt). 1. Make it as easy as possible for someone to run the notebook in Google Colab or some other environment based on standard practices like providing a `requirements.txt` file or anything else needed to successfully run the @@ -34,7 +35,10 @@ expected (for example `example.ipynb` will read some sample data from `data/data.csv`). If you are adding a notebook please try and add a similar cell to the top of the -notebook so that it is easy for others to run the notebook in colab. +notebook so that it is easy for others to run the notebook in colab. If your +notebook does not have any dependencies beyond what already comes as standard in +Google Colab then you do not need such a cell, just an "Open in Colab" badge +will suffice. ## example.ipynb diff --git a/notebooks/example/example.ipynb b/notebooks/example/example.ipynb index c9b873aa..2c6b1e01 100644 --- a/notebooks/example/example.ipynb +++ b/notebooks/example/example.ipynb @@ -1,5 +1,13 @@ { "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example Notebook" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -19,14 +27,6 @@ "# !pip install -r requirements.txt" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example Notebook" - ] - }, { "attachments": {}, "cell_type": "markdown", From 0c58b5d01f7c8b24af681ba063d5b746039b6fe8 Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 01:01:33 +0000 Subject: [PATCH 12/15] typo --- notebooks/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/README.md b/notebooks/README.md index fbe3a193..af8f24bc 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -1,6 +1,6 @@ # Notebooks -This is a folders with some useful notebooks, all the notebooks have a markdown +This is a folder with some useful notebooks, all the notebooks have a markdown file with the same name explaining what they do (or a README.md if its a single notebook folder). From 191ef2eeb2049e618ab66c170efb3802b27f4ff4 Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 01:02:23 +0000 Subject: [PATCH 13/15] dev --- notebooks/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebooks/README.md b/notebooks/README.md index af8f24bc..931f2fe5 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -1,8 +1,8 @@ # Notebooks This is a folder with some useful notebooks, all the notebooks have a markdown -file with the same name explaining what they do (or a README.md if its a single -notebook folder). +file with the same name (or a README.md if its a single notebook folder) +explaining what they do. ## Contributing From 1082c278793566a3a5efb04097c9b3acf4728cfc Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Sun, 8 Jan 2023 01:03:54 +0000 Subject: [PATCH 14/15] typo --- notebooks/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebooks/README.md b/notebooks/README.md index 931f2fe5..2eea7a15 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -6,8 +6,8 @@ explaining what they do. ## Contributing -Contributing to both notebooks and making new notebooks is very welcome. If you -do so, make sure to make a markdown (.md) file to go with your notebook, makes +Contributing to notebooks and making new notebooks is very welcome. If you do +so, make sure to make a markdown (.md) file to go with your notebook, it makes it easier for people to know what your notebook is about. Check out the [example notebook](example/) for a reference example you can use From 35ebefb64719581153cc4da4d55f3f37f9269856 Mon Sep 17 00:00:00 2001 From: Andrew Maguire Date: Tue, 10 Jan 2023 14:59:50 +0000 Subject: [PATCH 15/15] add `venv` to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9cdabc03..701701fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .venv +venv .env *.pyc *.swp