Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29ed78a

Browse files
committed
Better upload error handling.
1 parent 0b47813 commit 29ed78a

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

samples/outreach/blogs/segmentation_blogpost/image_segmentation.ipynb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,22 @@
144144
"cell_type": "markdown",
145145
"source": [
146146
"# Get all the files \n",
147-
"Since this tutorial will be using a dataset from Kaggle, it requires [creating an API Token](https://github.com/Kaggle/kaggle-api) for your Kaggle acccount, and uploading it. "
147+
"Since this tutorial will be using a dataset from Kaggle, it requires [creating an API Token](https://github.com/Kaggle/kaggle-api#api-credentials) for your Kaggle acccount, and uploading it. "
148148
]
149149
},
150+
{
151+
"metadata": {
152+
"id": "7jgdraTAiti0",
153+
"colab_type": "code",
154+
"colab": {}
155+
},
156+
"cell_type": "code",
157+
"source": [
158+
"rm /content/.kaggle/kaggle.json\n"
159+
],
160+
"execution_count": 0,
161+
"outputs": []
162+
},
150163
{
151164
"metadata": {
152165
"id": "sAVM1ZTmdAMR",
@@ -173,7 +186,11 @@
173186
" raise no_file\n",
174187
" \n",
175188
" uploaded = files.upload()\n",
176-
" with open(token_file, \"w\") as f:\n",
189+
" \n",
190+
" if \"kaggle.json\" not in uploaded:\n",
191+
" raise ValueError(\"You need an API key! see: \"\n",
192+
" \"https://github.com/Kaggle/kaggle-api#api-credentials\")\n",
193+
" with open(token_file, \"wb\") as f:\n",
177194
" f.write(uploaded[\"kaggle.json\"])\n",
178195
" os.chmod(token_file, 600)\n",
179196
"\n",

0 commit comments

Comments
 (0)