{ "cells": [ { "cell_type": "code", "execution_count": 4, "id": "74ee58a0-8c1a-4650-bb45-367214130cde", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Run this to confirm the notebook is working.\n" ] } ], "source": [ "print(\"Run this to confirm the notebook is working.\")" ] }, { "cell_type": "code", "execution_count": null, "id": "0889a582-4903-496f-99e7-7cdcdffe9f29", "metadata": {}, "outputs": [], "source": [ "# Please make sure you are logged in with `huggingface-cli login`" ] }, { "cell_type": "code", "execution_count": 2, "id": "40b30b76-185c-4404-b5ed-157a7c745ce1", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: huggingface_hub in /home/user/miniconda/lib/python3.9/site-packages (0.23.0)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/user/miniconda/lib/python3.9/site-packages (from huggingface_hub) (4.11.0)\n", "Requirement already satisfied: packaging>=20.9 in /home/user/miniconda/lib/python3.9/site-packages (from huggingface_hub) (24.0)\n", "Requirement already satisfied: tqdm>=4.42.1 in /home/user/miniconda/lib/python3.9/site-packages (from huggingface_hub) (4.61.2)\n", "Requirement already satisfied: pyyaml>=5.1 in /home/user/miniconda/lib/python3.9/site-packages (from huggingface_hub) (6.0.1)\n", "Requirement already satisfied: requests in /home/user/miniconda/lib/python3.9/site-packages (from huggingface_hub) (2.31.0)\n", "Requirement already satisfied: filelock in /home/user/miniconda/lib/python3.9/site-packages (from huggingface_hub) (3.14.0)\n", "Requirement already satisfied: fsspec>=2023.5.0 in /home/user/miniconda/lib/python3.9/site-packages (from huggingface_hub) (2024.5.0)\n", "Requirement already satisfied: idna<4,>=2.5 in /home/user/miniconda/lib/python3.9/site-packages (from requests->huggingface_hub) (2.10)\n", "Requirement already satisfied: certifi>=2017.4.17 in /home/user/miniconda/lib/python3.9/site-packages (from requests->huggingface_hub) (2021.5.30)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/user/miniconda/lib/python3.9/site-packages (from requests->huggingface_hub) (1.26.6)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /home/user/miniconda/lib/python3.9/site-packages (from requests->huggingface_hub) (3.3.2)\n" ] } ], "source": [ "!pip install huggingface_hub" ] }, { "cell_type": "code", "execution_count": 3, "id": "03ad7b5e-24ae-49e5-8fa7-e6b30260012f", "metadata": {}, "outputs": [], "source": [ "from huggingface_hub import HfApi\n", "\n", "api = HfApi()\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "f19b7b94-54d9-4c57-ad16-544b694d6d17", "metadata": { "tags": [] }, "outputs": [], "source": [ "uploaded_file_info = api.upload_file(\n", " path_or_fileobj=\"check.ipynb\",\n", " path_in_repo=\"check.ipynb\",\n", " repo_id=\"FlawedLLM/Jupyter_Amex\",\n", " repo_type=\"space\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "a7f4ee16-819d-4c43-a904-ed94b5d58a2f", "metadata": {}, "outputs": [], "source": [ "def upload_file(file_path, path_in_repo=\"check/\", repo_id=\"FlawedLLM/Jupyter_Amex\", upload_repo_type=\"space\"):\n", " uploaded_file_info = api.upload_file(\n", " path_or_fileobj=file_path,\n", " path_in_repo=path_in_repo+file_path.split(\"/\")[-1],\n", " repo_id=repo_id,\n", " repo_type=upload_repo_type,\n", " )" ] }, { "cell_type": "code", "execution_count": null, "id": "8e0a4c9c-995f-41a3-9e76-44a1f40bd5b7", "metadata": {}, "outputs": [], "source": [ "upload_file(file_path=\"check.ipynb\")" ] }, { "cell_type": "code", "execution_count": null, "id": "44ea87f0-c990-4edc-aaef-e5e190cec112", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.5" } }, "nbformat": 4, "nbformat_minor": 5 }