eldarab commited on
Commit
a9ae31d
·
1 Parent(s): c0f7f8f

Upload hub.ipynb

Browse files
Files changed (1) hide show
  1. hub.ipynb +157 -0
hub.ipynb ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "8cfa8aa6-d276-417e-8903-10887f6aebca",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import huggingface_hub as hub"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 34,
16
+ "id": "31c61098-c6ee-4466-a2e5-60337589367a",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "CEBAB = 'CEBaB'"
21
+ ]
22
+ },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": 2,
26
+ "id": "f9f929bc-5e76-445a-8e7d-43d4656c9583",
27
+ "metadata": {},
28
+ "outputs": [],
29
+ "source": [
30
+ "cebab_models = hub.list_models(filter=hub.ModelFilter(author=CEBAB))"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": 4,
36
+ "id": "0cd3bf15-58a4-4485-ac0b-b941748c6d12",
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "causalm_models = sorted([m.id for m in cebab_models if 'causalm' in m.id])"
41
+ ]
42
+ },
43
+ {
44
+ "cell_type": "code",
45
+ "execution_count": 25,
46
+ "id": "c608e3ba-52fa-4fbf-aa07-1158938a8596",
47
+ "metadata": {},
48
+ "outputs": [],
49
+ "source": [
50
+ "bert_causalm = [m for m in causalm_models if 'bert-base-uncased' in m and '__' in m]\n",
51
+ "roberta_causalm = [m for m in causalm_models if 'roberta-base' in m]\n",
52
+ "lstm_causalm = [m for m in causalm_models if 'lstm' in m]\n",
53
+ "gpt2_causalm = [m for m in causalm_models if 'gpt2' in m]"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "execution_count": 36,
59
+ "id": "67ce63fc-87d7-4024-9b6e-9430b7be54c7",
60
+ "metadata": {},
61
+ "outputs": [
62
+ {
63
+ "data": {
64
+ "application/vnd.jupyter.widget-view+json": {
65
+ "model_id": "a02948a164c74b80960a27911cd4a53a",
66
+ "version_major": 2,
67
+ "version_minor": 0
68
+ },
69
+ "text/plain": [
70
+ "VBox(children=(HTML(value='<center> <img\\nsrc=https://huggingface.co/front/assets/huggingface_logo-noborder.sv…"
71
+ ]
72
+ },
73
+ "metadata": {},
74
+ "output_type": "display_data"
75
+ }
76
+ ],
77
+ "source": [
78
+ "hub.notebook_login()"
79
+ ]
80
+ },
81
+ {
82
+ "cell_type": "code",
83
+ "execution_count": 37,
84
+ "id": "b0ad94fd-39d6-4490-bf41-a1591811b1cc",
85
+ "metadata": {},
86
+ "outputs": [
87
+ {
88
+ "name": "stderr",
89
+ "output_type": "stream",
90
+ "text": [
91
+ "C:\\Users\\Eldar-P14s\\anaconda3\\lib\\site-packages\\huggingface_hub\\hf_api.py:79: FutureWarning: `name` and `organization` input arguments are deprecated and will be removed in v0.7. Pass `repo_id` instead.\n",
92
+ " warnings.warn(\n"
93
+ ]
94
+ }
95
+ ],
96
+ "source": [
97
+ "repo_path = hub.create_repo(\n",
98
+ " organization=CEBAB,\n",
99
+ " name=f'eldar-try',\n",
100
+ " exist_ok=True\n",
101
+ ")"
102
+ ]
103
+ },
104
+ {
105
+ "cell_type": "code",
106
+ "execution_count": 43,
107
+ "id": "aa49404b-79a6-4ba5-b31c-1971fb7320bd",
108
+ "metadata": {},
109
+ "outputs": [
110
+ {
111
+ "ename": "HTTPError",
112
+ "evalue": "500 Server Error: Internal Server Error for url: https://huggingface.co/api/CEBaB/eldar-try/upload/main/",
113
+ "output_type": "error",
114
+ "traceback": [
115
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
116
+ "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)",
117
+ "\u001b[1;32m<ipython-input-43-b4c91946ae88>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m hub.upload_file(\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mpath_or_fileobj\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'hub.ipynb'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mrepo_id\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'CEBaB/eldar-try'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mpath_in_repo\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m )\n",
118
+ "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\huggingface_hub\\utils\\_deprecation.py\u001b[0m in \u001b[0;36minner_f\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m 30\u001b[0m \u001b[0mextra_args\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m-\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mall_args\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 31\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mextra_args\u001b[0m \u001b[1;33m<=\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 32\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 33\u001b[0m \u001b[1;31m# extra_args > 0\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 34\u001b[0m args_msg = [\n",
119
+ "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\huggingface_hub\\hf_api.py\u001b[0m in \u001b[0;36mupload_file\u001b[1;34m(self, path_or_fileobj, path_in_repo, repo_id, token, repo_type, revision, identical_ok)\u001b[0m\n\u001b[0;32m 1864\u001b[0m )\n\u001b[0;32m 1865\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1866\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1867\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1868\u001b[0m \u001b[0md\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
120
+ "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\huggingface_hub\\hf_api.py\u001b[0m in \u001b[0;36mupload_file\u001b[1;34m(self, path_or_fileobj, path_in_repo, repo_id, token, repo_type, revision, identical_ok)\u001b[0m\n\u001b[0;32m 1855\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1856\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1857\u001b[1;33m \u001b[0mr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mraise_for_status\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1858\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mHTTPError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1859\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0midentical_ok\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresponse\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstatus_code\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m409\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
121
+ "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\requests\\models.py\u001b[0m in \u001b[0;36mraise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 941\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 942\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mhttp_error_msg\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 943\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mHTTPError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhttp_error_msg\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mresponse\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 944\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 945\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mclose\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
122
+ "\u001b[1;31mHTTPError\u001b[0m: 500 Server Error: Internal Server Error for url: https://huggingface.co/api/CEBaB/eldar-try/upload/main/"
123
+ ]
124
+ }
125
+ ],
126
+ "source": [
127
+ "hub.upload_file(\n",
128
+ " path_or_fileobj=\"hub.ipynb\",\n",
129
+ " path_in_repo=\"\",\n",
130
+ " repo_id=\"username/my-model\",\n",
131
+ " token=\"my_token\",\n",
132
+ ")"
133
+ ]
134
+ }
135
+ ],
136
+ "metadata": {
137
+ "kernelspec": {
138
+ "display_name": "Python 3",
139
+ "language": "python",
140
+ "name": "python3"
141
+ },
142
+ "language_info": {
143
+ "codemirror_mode": {
144
+ "name": "ipython",
145
+ "version": 3
146
+ },
147
+ "file_extension": ".py",
148
+ "mimetype": "text/x-python",
149
+ "name": "python",
150
+ "nbconvert_exporter": "python",
151
+ "pygments_lexer": "ipython3",
152
+ "version": "3.8.8"
153
+ }
154
+ },
155
+ "nbformat": 4,
156
+ "nbformat_minor": 5
157
+ }