File size: 4,744 Bytes
ec54ab3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{
 "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
}