Move %store to try/catch block
This commit is contained in:
parent
648ba335b2
commit
d5d9b82f34
|
@ -147,9 +147,9 @@
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
|
|
||||||
"# You'll see this little code block at the beginning of every cell. It makes sure you have ran the first block that defines your settings.\n",
|
"# You'll see this little code block at the beginning of every cell. It makes sure you have ran the first block that defines your settings.\n",
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
|
||||||
" test = [symlink_to_notebooks, model_storage_dir, repo_storage_dir]\n",
|
" test = [symlink_to_notebooks, model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -206,8 +206,8 @@
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r symlink_to_notebooks model_storage_dir repo_storage_dir activate_xformers download_scripts activate_deepdanbooru\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r symlink_to_notebooks model_storage_dir repo_storage_dir activate_xformers download_scripts activate_deepdanbooru\n",
|
||||||
" test = [symlink_to_notebooks, model_storage_dir, repo_storage_dir, activate_xformers, download_scripts, activate_deepdanbooru]\n",
|
" test = [symlink_to_notebooks, model_storage_dir, repo_storage_dir, activate_xformers, download_scripts, activate_deepdanbooru]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -410,8 +410,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -440,8 +440,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -468,8 +468,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -496,8 +496,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -537,8 +537,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -567,8 +567,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -598,8 +598,8 @@
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -636,8 +636,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -665,8 +665,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -714,8 +714,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -741,8 +741,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -768,8 +768,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -797,8 +797,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -831,8 +831,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -869,8 +869,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -909,8 +909,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -952,8 +952,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -989,8 +989,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir link_novelai_anime_vae search_paperspace_datasets\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir link_novelai_anime_vae search_paperspace_datasets\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir, link_novelai_anime_vae, search_paperspace_datasets]\n",
|
" test = [model_storage_dir, repo_storage_dir, link_novelai_anime_vae, search_paperspace_datasets]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -1139,8 +1139,8 @@
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir activate_xformers activate_deepdanbooru activate_medvram disable_pickle_check gradio_port gradio_auth ui_theme insecure_extension_access\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir activate_xformers activate_deepdanbooru activate_medvram disable_pickle_check gradio_port gradio_auth ui_theme insecure_extension_access\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir, activate_xformers, activate_deepdanbooru, activate_medvram, disable_pickle_check, gradio_port, gradio_auth, ui_theme, insecure_extension_access]\n",
|
" test = [model_storage_dir, repo_storage_dir, activate_xformers, activate_deepdanbooru, activate_medvram, disable_pickle_check, gradio_port, gradio_auth, ui_theme, insecure_extension_access]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -1300,8 +1300,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -1410,8 +1410,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r model_storage_dir repo_storage_dir\n",
|
|
||||||
"try:\n",
|
"try:\n",
|
||||||
|
" %store -r model_storage_dir repo_storage_dir\n",
|
||||||
" test = [model_storage_dir, repo_storage_dir]\n",
|
" test = [model_storage_dir, repo_storage_dir]\n",
|
||||||
"except NameError as e:\n",
|
"except NameError as e:\n",
|
||||||
" print(\"There is an issue with your variables.\")\n",
|
" print(\"There is an issue with your variables.\")\n",
|
||||||
|
@ -1429,13 +1429,14 @@
|
||||||
" print(str)\n",
|
" print(str)\n",
|
||||||
" raise\n",
|
" raise\n",
|
||||||
"\n",
|
"\n",
|
||||||
"magnet_match = re.search(r'magnet:\\?xt=urn:btih:[\\-_A-Za-z0-9&=%.]*', model_uri)\n",
|
"magnet_match = re.search(r'magnet:\\?xt=urn:btih:[A-Za-z0-9&=%.]*', model_uri)\n",
|
||||||
"web_match = re.search(r'(https?:\\/\\/(?:www\\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|www\\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|https?:\\/\\/(?:www\\.|(?!www))[a-zA-Z0-9]+\\.[^\\s]{2,}|www\\.[a-zA-Z0-9]+\\.[^\\s]{2,})', model_uri)\n",
|
"web_match = re.search(r'(https?:\\/\\/(?:www\\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|www\\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|https?:\\/\\/(?:www\\.|(?!www))[a-zA-Z0-9]+\\.[^\\s]{2,}|www\\.[a-zA-Z0-9]+\\.[^\\s]{2,})', model_uri)\n",
|
||||||
"web_dl_file = None\n",
|
"web_dl_file = None\n",
|
||||||
"gdrive_file_id = None\n",
|
"gdrive_file_id = None\n",
|
||||||
"\n",
|
"\n",
|
||||||
"if magnet_match:\n",
|
"if magnet_match:\n",
|
||||||
" !if [ $(dpkg-query -W -f='${Status}' aria2 2>/dev/null | grep -c \"ok installed\") = 0 ]; then sudo apt update && sudo apt install -y aria2; fi\n",
|
" !apt update\n",
|
||||||
|
" !apt install -y aria2\n",
|
||||||
" %cd \"{model_storage_dir}\"\n",
|
" %cd \"{model_storage_dir}\"\n",
|
||||||
" bash_var = magnet_match[0]\n",
|
" bash_var = magnet_match[0]\n",
|
||||||
" !aria2c --seed-time=0 --max-overall-upload-limit=1K --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"{bash_var}\"\n",
|
" !aria2c --seed-time=0 --max-overall-upload-limit=1K --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"{bash_var}\"\n",
|
||||||
|
@ -1466,8 +1467,8 @@
|
||||||
"elif gdrive_file_id is not None:\n",
|
"elif gdrive_file_id is not None:\n",
|
||||||
" %cd \"{model_storage_dir}\"\n",
|
" %cd \"{model_storage_dir}\"\n",
|
||||||
" gdown.download(f\"https://drive.google.com/uc?id={gdrive_file_id}&confirm=t\")\n",
|
" gdown.download(f\"https://drive.google.com/uc?id={gdrive_file_id}&confirm=t\")\n",
|
||||||
"elif magnet_match: pass\n",
|
"else:\n",
|
||||||
"else: print('Could not parse your URI.')"
|
" print('Could not parse your URI.')"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue