{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "MNrSAzxQGJuq" }, "source": [ "# Notebook 1: Collect, augment and publish a GitHub issues dataset\n", "\n", "**Source:** public issues of the `scikit-learn/scikit-learn` repository, via the GitHub REST API\n", "**Published dataset:** https://huggingface.co/datasets/BeNatural/github-scikit-learn-issues-dataset\n", "\n", "**What this notebook does**\n", "1. Explores one API response to see what GitHub returns.\n", "2. Collects 300 issues with the `requests` library, removing pull requests.\n", "3. Builds a structured table and adds two derived fields.\n", "4. Cleans and validates the data.\n", "5. Summarises the data (these figures are used in the dataset card).\n", "6. Saves CSV and Parquet files.\n", "7. Logs in to Hugging Face and pushes the files to the Hub.\n", "8. Checks that the published dataset loads correctly." ], "id": "MNrSAzxQGJuq" }, { "cell_type": "markdown", "metadata": { "id": "ViOkKMuiGJur" }, "source": [ "## 1. Setup" ], "id": "ViOkKMuiGJur" }, { "cell_type": "code", "metadata": { "id": "n9QXTUPcGJur" }, "execution_count": 1, "outputs": [], "source": [ "!pip install -q requests pandas pyarrow huggingface_hub datasets" ], "id": "n9QXTUPcGJur" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "XAyOTWUsGJus", "outputId": "4db47633-1309-4c46-eeff-44c87d22b960" }, "execution_count": 2, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Collection date: 2026-11-05\n" ] } ], "source": [ "import time\n", "import datetime\n", "import requests\n", "import pandas as pd\n", "from pathlib import Path\n", "\n", "API_URL = \"https://api.github.com/repos/scikit-learn/scikit-learn/issues\"\n", "TARGET = 300 # number of genuine issues to collect\n", "HF_REPO = \"BeNatural/github-scikit-learn-issues-dataset\"\n", "\n", "collection_date = datetime.date.today()\n", "print(\"Collection date:\", collection_date)" ], "id": "XAyOTWUsGJus" }, { "cell_type": "markdown", "metadata": { "id": "3vShOl8kGJus" }, "source": [ "## 2. Explore one API response\n", "First, one small request to see what GitHub returns. GitHub's issues endpoint returns **both issues and pull requests**. A pull request can be recognised because it has a `pull_request` field." ], "id": "3vShOl8kGJus" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "8xJ6GA-RGJus", "outputId": "afc5e9db-6e4f-4b5a-f4df-f2911859c285" }, "execution_count": 3, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Status code: 200\n", "Records received: 5\n", "35315 | pull request? True | MNT bump vendored array-api-compat to 1.16\n", "35314 | pull request? True | WIP MNT Add CI job that tests for thread-safety bugs by enab\n", "35313 | pull request? False | Add CI job with threaded parallelism on by default, to catch\n", "35312 | pull request? True | DOC/TST document and test GaussianNB var_smoothing\n", "35311 | pull request? True | PRF Compute KMeans' tolerance without np.var on dense data\n" ] } ], "source": [ "response = requests.get(API_URL, params={\"state\": \"all\", \"per_page\": 5}, timeout=30)\n", "print(\"Status code:\", response.status_code) # 200 means success\n", "response.raise_for_status()\n", "\n", "sample = response.json()\n", "print(\"Records received:\", len(sample))\n", "for item in sample:\n", " print(item[\"number\"], \"| pull request?\", \"pull_request\" in item, \"|\", item[\"title\"][:60])" ], "id": "8xJ6GA-RGJus" }, { "cell_type": "markdown", "metadata": { "id": "hvlJozP-GJus" }, "source": [ "## 3. Collect the issues\n", "- `state=all` returns open and closed issues.\n", "- `sort=created` and `direction=asc` return the **oldest issues first**.\n", "- `per_page=100` is the maximum page size.\n", "- Pull requests are skipped, so only genuine issues are kept.\n", "- A short pause between pages avoids overloading the API.\n", "- Collection stops once 300 issues have been gathered, and the list is trimmed to exactly 300.\n", "\n", "No access token is needed for this small number of requests, because the public API allows it within its rate limits." ], "id": "hvlJozP-GJus" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "uwOzTrypGJus", "outputId": "a336ad8f-607c-430c-eab4-57f76eeb906e" }, "execution_count": 4, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Page 1: issues collected so far = 47\n", "Page 2: issues collected so far = 79\n", "Page 3: issues collected so far = 110\n", "Page 4: issues collected so far = 155\n", "Page 5: issues collected so far = 183\n", "Page 6: issues collected so far = 224\n", "Page 7: issues collected so far = 266\n", "Page 8: issues collected so far = 318\n", "\n", "FINAL TOTAL: 300\n" ] } ], "source": [ "all_issues = []\n", "page = 1\n", "\n", "while len(all_issues) < TARGET:\n", " response = requests.get(\n", " API_URL,\n", " params={\n", " \"state\": \"all\",\n", " \"per_page\": 100,\n", " \"page\": page,\n", " \"sort\": \"created\",\n", " \"direction\": \"asc\",\n", " },\n", " timeout=30,\n", " )\n", " response.raise_for_status()\n", " records = response.json()\n", "\n", " if not records: # no more pages\n", " break\n", "\n", " for item in records:\n", " if \"pull_request\" not in item: # keep genuine issues only\n", " all_issues.append(item)\n", "\n", " print(f\"Page {page}: issues collected so far = {len(all_issues)}\")\n", " page += 1\n", " time.sleep(0.5)\n", "\n", "all_issues = all_issues[:TARGET]\n", "print(\"\\nFINAL TOTAL:\", len(all_issues))" ], "id": "uwOzTrypGJus" }, { "cell_type": "markdown", "metadata": { "id": "IZSAkeJdGJut" }, "source": [ "GitHub returns many fields for each issue. Here is the list, so we can choose which ones to keep." ], "id": "IZSAkeJdGJut" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "VWelh0j8GJut", "outputId": "291baeb2-67ea-4be5-957c-9ff3d6c6a98b" }, "execution_count": 5, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "['url', 'repository_url', 'labels_url', 'comments_url', 'events_url', 'html_url', 'id', 'node_id', 'number', 'title', 'user', 'labels', 'state', 'locked', 'assignees', 'milestone', 'comments', 'created_at', 'updated_at', 'closed_at', 'assignee', 'author_association', 'issue_field_values', 'type', 'active_lock_reason', 'sub_issues_summary', 'issue_dependencies_summary', 'body', 'closed_by', 'reactions', 'timeline_url', 'performed_via_github_app', 'state_reason', 'pinned_comment']\n" ] } ], "source": [ "print(list(all_issues[0].keys()))" ], "id": "VWelh0j8GJut" }, { "cell_type": "markdown", "metadata": { "id": "4oC9iMWnGJut" }, "source": [ "## 4. Build the table and add derived fields\n", "Fourteen fields are kept. Two of them are **derived** (calculated by us, not given by GitHub):\n", "- `text_length`: number of characters in the title and body together.\n", "- `time_to_close_hours`: hours between `created_at` and `closed_at` (empty for open issues).\n", "\n", "Text is stripped of leading and trailing spaces, a missing body becomes empty text, and the list of labels is joined into one comma-separated text field." ], "id": "4oC9iMWnGJut" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 397 }, "id": "lfv3S4LNGJut", "outputId": "b49065d0-f44d-4a5d-ced2-b63a436020f7" }, "execution_count": 6, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Dataset shape: (300, 14)\n" ] }, { "output_type": "execute_result", "data": { "text/plain": [ " issue_id issue_number repository \\\n", "0 295764 1 scikit-learn/scikit-learn \n", "1 311965 5 scikit-learn/scikit-learn \n", "2 369933 7 scikit-learn/scikit-learn \n", "3 378489 8 scikit-learn/scikit-learn \n", "4 382343 11 scikit-learn/scikit-learn \n", "\n", " title \\\n", "0 remove Y from fit in OneClassSVM \n", "1 Bayesian regression \n", "2 Return index of support vectors in sparse SVM \n", "3 LARS module broken \n", "4 implement warm restarts for logistic regression \n", "\n", " body state \\\n", "0 closed \n", "1 Add priors on the mean instead of assuming tha... closed \n", "2 Assigned to me closed \n", "3 - the parameter names are different in docstri... closed \n", "4 assigned to me closed \n", "\n", " labels created_at closed_at \\\n", "0 2010-08-31 07:38:16+00:00 2010-08-31 07:43:11+00:00 \n", "1 2010-09-11 11:40:28+00:00 2012-01-06 13:37:31+00:00 \n", "2 Enhancement, Moderate 2010-10-19 08:00:57+00:00 2013-02-02 16:08:16+00:00 \n", "3 2010-10-23 23:04:24+00:00 2010-11-25 11:09:11+00:00 \n", "4 New Feature 2010-10-26 07:28:50+00:00 2014-10-12 15:30:46+00:00 \n", "\n", " comments author html_url \\\n", "0 0 fabianp https://github.com/scikit-learn/scikit-learn/i... \n", "1 11 vmichel https://github.com/scikit-learn/scikit-learn/i... \n", "2 2 fabianp https://github.com/scikit-learn/scikit-learn/i... \n", "3 5 satra https://github.com/scikit-learn/scikit-learn/i... \n", "4 12 fabianp https://github.com/scikit-learn/scikit-learn/i... \n", "\n", " text_length time_to_close_hours \n", "0 33 0.081944 \n", "1 443 11569.950833 \n", "2 60 20096.121944 \n", "3 349 780.079722 \n", "4 62 34736.032222 " ], "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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
issue_idissue_numberrepositorytitlebodystatelabelscreated_atclosed_atcommentsauthorhtml_urltext_lengthtime_to_close_hours
02957641scikit-learn/scikit-learnremove Y from fit in OneClassSVMclosed2010-08-31 07:38:16+00:002010-08-31 07:43:11+00:000fabianphttps://github.com/scikit-learn/scikit-learn/i...330.081944
13119655scikit-learn/scikit-learnBayesian regressionAdd priors on the mean instead of assuming tha...closed2010-09-11 11:40:28+00:002012-01-06 13:37:31+00:0011vmichelhttps://github.com/scikit-learn/scikit-learn/i...44311569.950833
23699337scikit-learn/scikit-learnReturn index of support vectors in sparse SVMAssigned to meclosedEnhancement, Moderate2010-10-19 08:00:57+00:002013-02-02 16:08:16+00:002fabianphttps://github.com/scikit-learn/scikit-learn/i...6020096.121944
33784898scikit-learn/scikit-learnLARS module broken- the parameter names are different in docstri...closed2010-10-23 23:04:24+00:002010-11-25 11:09:11+00:005satrahttps://github.com/scikit-learn/scikit-learn/i...349780.079722
438234311scikit-learn/scikit-learnimplement warm restarts for logistic regressionassigned to meclosedNew Feature2010-10-26 07:28:50+00:002014-10-12 15:30:46+00:0012fabianphttps://github.com/scikit-learn/scikit-learn/i...6234736.032222
\n", "
\n", "
\n", "\n", "
\n", " \n", "\n", " \n", "\n", " \n", "
\n", "\n", "\n", "
\n", "
\n" ], "application/vnd.google.colaboratory.intrinsic+json": { "type": "dataframe", "variable_name": "df", "summary": "{\n \"name\": \"df\",\n \"rows\": 300,\n \"fields\": [\n {\n \"column\": \"issue_id\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1156320,\n \"min\": 295764,\n \"max\": 4103370,\n \"num_unique_values\": 300,\n \"samples\": [\n 2870227,\n 3681083,\n 1922616\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"issue_number\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 231,\n \"min\": 1,\n \"max\": 768,\n \"num_unique_values\": 300,\n \"samples\": [\n 565,\n 703,\n 395\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"repository\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"scikit-learn/scikit-learn\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 300,\n \"samples\": [\n \"grid search keeps all estimators in memory\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"body\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 291,\n \"samples\": [\n \"Just a note to remember that we can arguably still greatly improve the Coordinate Descent (lasso / elastic net) convergence speed if we implement the following trick:\\n\\nhttp://www-stat.stanford.edu/~tibs/ftp/strong.pdf\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"state\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"open\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"labels\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 19,\n \"samples\": [\n \"\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"created_at\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2010-08-31 07:38:16+00:00\",\n \"max\": \"2012-04-13 13:40:27+00:00\",\n \"num_unique_values\": 300,\n \"samples\": [\n \"2012-01-17 15:43:10+00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"closed_at\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2010-08-31 07:43:11+00:00\",\n \"max\": \"2025-11-05 16:50:43+00:00\",\n \"num_unique_values\": 295,\n \"samples\": [\n \"2012-03-25 22:18:29+00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"comments\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 8,\n \"min\": 0,\n \"max\": 59,\n \"num_unique_values\": 35,\n \"samples\": [\n 23\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"author\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 84,\n \"samples\": [\n \"benjaminwilson\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"html_url\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 300,\n \"samples\": [\n \"https://github.com/scikit-learn/scikit-learn/issues/565\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"text_length\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 958,\n \"min\": 33,\n \"max\": 6922,\n \"num_unique_values\": 264,\n \"samples\": [\n 325\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"time_to_close_hours\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 18537.589444119472,\n \"min\": 0.08194444444444444,\n \"max\": 125742.1775,\n \"num_unique_values\": 295,\n \"samples\": [\n 1.9425\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" } }, "metadata": {}, "execution_count": 6 } ], "source": [ "rows = []\n", "\n", "for issue in all_issues:\n", " labels = [label[\"name\"] for label in issue.get(\"labels\", [])]\n", "\n", " created = pd.to_datetime(issue[\"created_at\"], utc=True)\n", " closed = pd.to_datetime(issue[\"closed_at\"], utc=True, errors=\"coerce\")\n", "\n", " title = (issue.get(\"title\") or \"\").strip()\n", " body = (issue.get(\"body\") or \"\").strip()\n", "\n", " rows.append({\n", " \"issue_id\": issue[\"id\"],\n", " \"issue_number\": issue[\"number\"],\n", " \"repository\": \"scikit-learn/scikit-learn\",\n", " \"title\": title,\n", " \"body\": body,\n", " \"state\": issue[\"state\"],\n", " \"labels\": \", \".join(labels),\n", " \"created_at\": created,\n", " \"closed_at\": closed,\n", " \"comments\": issue[\"comments\"],\n", " \"author\": (issue.get(\"user\") or {}).get(\"login\"),\n", " \"html_url\": issue[\"html_url\"],\n", " \"text_length\": len(title + \" \" + body),\n", " \"time_to_close_hours\": (\n", " (closed - created).total_seconds() / 3600 if pd.notna(closed) else None\n", " ),\n", " })\n", "\n", "df = pd.DataFrame(rows)\n", "print(\"Dataset shape:\", df.shape)\n", "df.head()" ], "id": "lfv3S4LNGJut" }, { "cell_type": "markdown", "metadata": { "id": "qawWzss_GJut" }, "source": [ "## 5. Cleaning and validation\n", "1. Remove duplicate issues (same `issue_id`).\n", "2. Remove records with a missing or empty title.\n", "3. Reset the row numbers.\n", "4. Check the result with assertions. If any check fails, the notebook stops with an error.\n", "\n", "Missing values that are genuine (no `closed_at` for open issues, empty bodies, no labels) are **kept, not filled in**, because they carry real information." ], "id": "qawWzss_GJut" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "JUoK2KBFGJut", "outputId": "fce03c3e-1ea5-4416-82cf-249c470f132e" }, "execution_count": 7, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Rows before cleaning: 300\n", "Rows after cleaning: 300\n", "\n", "Missing values per column:\n", "issue_id 0\n", "issue_number 0\n", "repository 0\n", "title 0\n", "body 0\n", "state 0\n", "labels 0\n", "created_at 0\n", "closed_at 5\n", "comments 0\n", "author 0\n", "html_url 0\n", "text_length 0\n", "time_to_close_hours 5\n", "dtype: int64\n", "\n", "Validation successful!\n" ] } ], "source": [ "before = len(df)\n", "\n", "df = df.drop_duplicates(subset=\"issue_id\").copy()\n", "df = df[df[\"title\"].notna()].copy()\n", "df = df[df[\"title\"].str.strip() != \"\"].copy()\n", "df = df.reset_index(drop=True)\n", "\n", "print(\"Rows before cleaning:\", before)\n", "print(\"Rows after cleaning: \", len(df))\n", "print()\n", "print(\"Missing values per column:\")\n", "print(df.isna().sum())\n", "\n", "assert df[\"issue_id\"].is_unique\n", "assert df[\"title\"].str.strip().ne(\"\").all()\n", "assert not df[\"html_url\"].str.contains(\"/pull/\").any() # no pull requests\n", "assert 200 <= len(df) <= 500\n", "print(\"\\nValidation successful!\")" ], "id": "JUoK2KBFGJut" }, { "cell_type": "markdown", "metadata": { "id": "Z5MsQyE6GJut" }, "source": [ "## 6. Summary of the data\n", "These figures are the ones reported in the dataset card (README), so they can be checked against it." ], "id": "Z5MsQyE6GJut" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "a3f9GbPMGJuu", "outputId": "e224c8f6-43d8-473e-8b4e-e005df6941fc" }, "execution_count": 8, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Rows / columns: (300, 14)\n", "Date range: 2010-08-31 07:38:16+00:00 to 2012-04-13 13:40:27+00:00\n", "Issue numbers: 1 to 768\n", "\n", "State:\n", "state\n", "closed 295\n", "open 5\n", "Name: count, dtype: int64\n", "\n", "Empty bodies: 9\n", "Issues without labels: 235\n", "Issues with labels: 65\n", "\n", "Most common labels:\n", "labels\n", "New Feature 21\n", "Enhancement 11\n", "Bug 7\n", "Enhancement, Moderate 5\n", "Easy, Enhancement 5\n", "Name: count, dtype: int64\n", "\n", "Comments per issue: 4.0 (median), 7.2 (mean), 59 (max)\n", "Median hours to close: 1194.7\n", "\n", "Distinct authors: 84\n", "Top 3 authors: {'amueller': 49, 'fabianp': 47, 'mblondel': 36} -> 132 of 300 issues\n" ] } ], "source": [ "print(\"Rows / columns:\", df.shape)\n", "print(\"Date range:\", df[\"created_at\"].min(), \"to\", df[\"created_at\"].max())\n", "print(\"Issue numbers:\", df[\"issue_number\"].min(), \"to\", df[\"issue_number\"].max())\n", "print()\n", "print(\"State:\")\n", "print(df[\"state\"].value_counts())\n", "print()\n", "print(\"Empty bodies:\", (df[\"body\"] == \"\").sum())\n", "print(\"Issues without labels:\", (df[\"labels\"] == \"\").sum())\n", "print(\"Issues with labels:\", (df[\"labels\"] != \"\").sum())\n", "print()\n", "print(\"Most common labels:\")\n", "print(df.loc[df[\"labels\"] != \"\", \"labels\"].value_counts().head(5))\n", "print()\n", "print(\"Comments per issue:\", df[\"comments\"].median(), \"(median),\", round(df[\"comments\"].mean(), 1), \"(mean),\", df[\"comments\"].max(), \"(max)\")\n", "print(\"Median hours to close:\", round(df[\"time_to_close_hours\"].median(), 1))\n", "print()\n", "top3 = df[\"author\"].value_counts().head(3)\n", "print(\"Distinct authors:\", df[\"author\"].nunique())\n", "print(\"Top 3 authors:\", top3.to_dict(), \"->\", top3.sum(), \"of\", len(df), \"issues\")" ], "id": "a3f9GbPMGJuu" }, { "cell_type": "markdown", "metadata": { "id": "9QTBFqJQGJuu" }, "source": [ "## 7. Save the data locally" ], "id": "9QTBFqJQGJuu" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "DeteIsLVGJuu", "outputId": "a92188f0-b0f2-4a1f-9671-daa241f55dee" }, "execution_count": 9, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Saved: ['github_issues.csv', 'github_issues.parquet']\n" ] } ], "source": [ "Path(\"data\").mkdir(exist_ok=True)\n", "\n", "df.to_csv(\"data/github_issues.csv\", index=False)\n", "df.to_parquet(\"data/github_issues.parquet\", index=False)\n", "\n", "print(\"Saved:\", [p.name for p in Path(\"data\").iterdir()])" ], "id": "DeteIsLVGJuu" }, { "cell_type": "markdown", "metadata": { "id": "eH2epdyfGJuu" }, "source": [ "## 8. Log in to Hugging Face and push the dataset\n", "Pushing to the Hub needs a **Hugging Face access token with write permission**. The token is a password, so it must never be typed into the notebook or saved in it.\n", "\n", "In Colab, store it as a *secret*:\n", "1. Click the **key icon** in the left sidebar.\n", "2. Click **Add new secret**. Name it `HF_TOKEN` and paste your token as the value.\n", "3. Switch on **Notebook access**.\n", "\n", "The code reads the token from the secret and nothing is printed or saved. If no secret is found, it asks for the token with a hidden input box." ], "id": "eH2epdyfGJuu" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Sum2ayzrGJuu", "outputId": "dc973185-fa9d-4fa0-af80-e242b6f255f1" }, "execution_count": 10, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Hugging Face token (input is hidden): \u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\n", "Logged in to Hugging Face.\n" ] } ], "source": [ "from huggingface_hub import login, HfApi\n", "\n", "try:\n", " from google.colab import userdata\n", " hf_token = userdata.get(\"HF_TOKEN\")\n", "except Exception:\n", " from getpass import getpass\n", " hf_token = getpass(\"Hugging Face token (input is hidden): \")\n", "\n", "login(token=hf_token)\n", "print(\"Logged in to Hugging Face.\")" ], "id": "Sum2ayzrGJuu" }, { "cell_type": "markdown", "metadata": { "id": "DVBGV69_GJuu" }, "source": [ "The files are uploaded to the dataset repository. The Parquet file is the main data file. The existing dataset card (README) is not changed." ], "id": "DVBGV69_GJuu" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 232, "referenced_widgets": [ "804bc001e21f40028314ce58744533be", "44b135d73f1545b491aa57fc4a4c6f87", "a8d8e6dcebf94d939377eea7c812493f", "624537e9cf9247e59febeb6f08780c19", "cfb782e9c9f4492290104b65a55a4140", "5ff45fd89c6842fcabadfd03ca8bb69b", "fb3f4778901a4ba1977032f980232f63", "a05d3f28b40b450ab329b3c3d06917e0", "7eea8dbc943d44f491310831c93a7cbe", "604ae23cacb8478b87c0a5053ef11058", "fbe4ccc17d18483b8b030947cf178360", "7b3234dc0f114b08b0e814d39650bfa6", "9ffe9b19991d44b8a87213ee146d6abf", "62aaee3388ba4c1da609f69d6c3e2bdc", "cd67c9a1cedf4e139194d9a6d53bd13a", "6067637d89814a2ca6fe008694da31c8", "cc8f0556a5c844db9be2bb423a82dcf4", "2739ca40e760437f910fd63f7d0f861e", "4aa1a3c8401d474cbcc2c6ef17151144", "55715c00489e4d38bb4202d5d1f89003", "7204e456881b4533ac07760f2dd0ecd2", "e0a5a392a7924add8ab1d61cc809b1e1", "8a422f24d5ed41ea9f64a08f0115d901", "e5a637af98194759bea6fa0d62348e97", "9cc4610a4a304f2fb975e8d10a90a282", "4406c724b63b478cbc3965c182c83bec", "a5f406b7ea614a6b8d5f03c74d9d5570", "a779684422b04eb788572527284965b8", "c3b628a26d8f4f58ac9663ff21a13953", "13d21103dc5549ac97b61c6372b158f5", "332cf7b2b7ad46e7bd1187708deeea72", "d48ae28d4a8e4d148176e8b042cd3d6c", "25a82f3d2c8a4027afbf3c626291fc5f", "8f3591aa21c143a5b214c52fd5bc84c3", "87fc7cb466ba4f0d8b8069618b98d4d0", "7fc8d369b17745c7a71892fd80a2b4eb", "2ead0823208e4773b3ce642459461723", "ad33652421f64b2c8348707bcaa4c7f7", "491d02999c1d4c0d9bf654e5e81bf9cf", "d36256f9ea57408d8e86f77e4d4f1d6a", "7cc3d6cc1f4a4e32b30f939f07749d41", "814b879820814f6cbd6efa04a749b217", "f9eba6dcf64a4a528d2eca2723d3590e", "a5ba500883374745adbfe14ce2a8efc2" ] }, "id": "DI-fzewrGJuu", "outputId": "fa7f8d67-d149-402a-8cae-737b206f8b5a" }, "execution_count": 11, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "Processing Files (0 / 0) : | | 0.00B / 0.00B " ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "804bc001e21f40028314ce58744533be" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "New Data Upload : | | 0.00B / 0.00B " ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "7b3234dc0f114b08b0e814d39650bfa6" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ " ...ata/github_issues.parquet: 100%|##########| 135kB / 135kB " ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "8a422f24d5ed41ea9f64a08f0115d901" } }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "Validating : | 0% " ], "application/vnd.jupyter.widget-view+json": { "version_major": 2, "version_minor": 0, "model_id": "8f3591aa21c143a5b214c52fd5bc84c3" } }, "metadata": {} }, { "output_type": "stream", "name": "stderr", "text": [ "No files have been modified since last commit. Skipping to prevent empty commit.\n", "WARNING:huggingface_hub.hf_api:No files have been modified since last commit. Skipping to prevent empty commit.\n", "No files have been modified since last commit. Skipping to prevent empty commit.\n", "WARNING:huggingface_hub.hf_api:No files have been modified since last commit. Skipping to prevent empty commit.\n" ] }, { "output_type": "stream", "name": "stdout", "text": [ "Pushed to https://huggingface.co/datasets/BeNatural/github-scikit-learn-issues-dataset\n" ] } ], "source": [ "api = HfApi()\n", "\n", "api.create_repo(repo_id=HF_REPO, repo_type=\"dataset\", exist_ok=True)\n", "\n", "api.upload_file(\n", " path_or_fileobj=\"data/github_issues.parquet\",\n", " path_in_repo=\"github_issues.parquet\",\n", " repo_id=HF_REPO,\n", " repo_type=\"dataset\",\n", " commit_message=\"Upload GitHub issues dataset (Parquet) from collection notebook\",\n", ")\n", "\n", "api.upload_file(\n", " path_or_fileobj=\"data/github_issues.csv\",\n", " path_in_repo=\"github_scikit-learn_issues.csv\",\n", " repo_id=HF_REPO,\n", " repo_type=\"dataset\",\n", " commit_message=\"Upload GitHub issues dataset (CSV) from collection notebook\",\n", ")\n", "\n", "print(\"Pushed to https://huggingface.co/datasets/\" + HF_REPO)" ], "id": "DI-fzewrGJuu" }, { "cell_type": "markdown", "metadata": { "id": "5YQVX-oFGJuv" }, "source": [ "## 9. Check the published dataset" ], "id": "5YQVX-oFGJuv" }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 180, "referenced_widgets": [ "7f24bb0c8e5c4f349554d06ab8e5007d", "6a695731a36d4ac0b4d27186618058bd", "b39b59663d4e4da5bcd6713a547c9a47", "a5b71b3fa277475290767300c14439aa", "734e788c12a240c49ee6e686177593c8", "aaa22ac23c5a484d97c93b20dfad4287", "014d0a6a7504475a93f28648a5332e53", "240da2ae0f6149a897cd5aea8a565dd6", "7acc684e1ee1442284c547e6b5fcfd21", "65d4f60121f54250b9ef106ebb0b3578", "d641c3c572e24e0ba403b407a973a9c1", "de2f3394ef314bdab788c3de95651db1", "1e8eb717e6474fffbe4450dcdb0afdfb", "57dbc062a3e24a998693167492e34a51", "a2826c8b1fdd44dcad16cfda3a6421ba", "2ddacb6f1b2846529801af7bcba073eb", "7a05836c536e4550a1e34a02114e5253", "de9bd642b63443cca1900114892e33c7", "4a0b39d3697b4ef49c1ecd32421982e5", "55ab9c7530fd4944b95d8547d09b0082", "16603b8d7e40484a85026e56f65aa556", "97e4c9ae536447f8890ff50ce2ecf939", "acc0de67c067421c875927acce46a28b", "9b541dcc30004b16a0e76dbb41bcce80", "b60a644338cb46bd9ea74457c923f7d8", "65e8cdc56076433d8f8dafe3f8dc9e0f", "5ef2f16cc26844d2bbeabf93f2167fe8", "78bf90699acf451e96b393783d2bd613", "edf1dd8d383641c0bb4d26a2dda632a1", "1a3799d3b8554aa4b3c37fe861e1aa5c", "219528f4c6e945ea97a32559a5ba6a26", "99970130d29e45e4ae6de8165e620962", "f3154d61172346db85673e8ade3452a1", "acc137bd8b3944708c44ac06970e9f5a", "4289f4dfa1734921ba9180a76531c3b6", "bf46d912bff34bd7bce433d072d923ea", "c4d972a3d0964c9194cbfcbdb6f99d0f", "8992a7de496b4887a38d1fbfde6da826", "bda8bfdd946f4e8b92b6c492339b2ce9", "00af2b14218c46e698c2dfd794dc0246", "7f35a232608b490aa6dc20a50ee866bb", "74fa994f627e42e8b10a4951fc988d47", "31f64058053942c29eae00517f76863d", "f464fc8e681e41c6a2a077a1fba6d2ba" ] }, "id": "3cnIKZxgGJuv", "outputId": "999694ca-e5ac-4aa3-d3c8-a216bd4dba96" }, "execution_count": 12, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "README.md: 0%| | 0.00/8.64k [00:00