Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions JupyterHub_Help.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,26 @@
"import zipfile\n",
"import io\n",
"import shutil\n",
"from tqdm.notebook import tqdm\n",
"\n",
"url = \"https://github.com/jgieseler/workshop3_data/archive/refs/heads/main.zip\"\n",
"data_folder = \"/home/jovyan/data\"\n",
"\n",
"with urllib.request.urlopen(url) as response:\n",
" with zipfile.ZipFile(io.BytesIO(response.read())) as z:\n",
" z.extractall(data_folder)\n",
" total = int(response.headers.get(\"Content-Length\", 0))\n",
" chunk_size = 1024 * 1024 # 1 MB chunks\n",
" data = io.BytesIO()\n",
" with tqdm(total=total, unit=\"B\", unit_scale=True, desc=\"Downloading\") as pbar:\n",
" while True:\n",
" chunk = response.read(chunk_size)\n",
" if not chunk:\n",
" break\n",
" data.write(chunk)\n",
" pbar.update(len(chunk))\n",
" data.seek(0)\n",
"\n",
"with zipfile.ZipFile(data) as z:\n",
" z.extractall(data_folder)\n",
"\n",
"# GitHub adds a \"workshop3_data-main/\" subfolder, move contents up\n",
"shutil.copytree(f\"{data_folder}/workshop3_data-main/\", data_folder, dirs_exist_ok=True)\n",
Expand Down
Loading