From d5d9b82f3497e24fc468f007941b4049000b4da0 Mon Sep 17 00:00:00 2001 From: Cyberes <64224601+Cyberes@users.noreply.github.com> Date: Sat, 31 Dec 2022 17:30:50 -0700 Subject: [PATCH] Move %store to try/catch block --- StableDiffusionUI_Voldemort_paperspace.ipynb | 55 ++++++++++---------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/StableDiffusionUI_Voldemort_paperspace.ipynb b/StableDiffusionUI_Voldemort_paperspace.ipynb index 1d81cfc..8711d76 100644 --- a/StableDiffusionUI_Voldemort_paperspace.ipynb +++ b/StableDiffusionUI_Voldemort_paperspace.ipynb @@ -147,9 +147,9 @@ "outputs": [], "source": [ "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", "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", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -206,8 +206,8 @@ }, "outputs": [], "source": [ - "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir activate_xformers download_scripts activate_deepdanbooru\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", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -410,8 +410,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -440,8 +440,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -468,8 +468,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -496,8 +496,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -537,8 +537,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -567,8 +567,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -598,8 +598,8 @@ }, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -636,8 +636,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -665,8 +665,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -714,8 +714,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -741,8 +741,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -768,8 +768,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -797,8 +797,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -831,8 +831,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -869,8 +869,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -909,8 +909,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -952,8 +952,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -989,8 +989,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir link_novelai_anime_vae search_paperspace_datasets\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", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -1139,8 +1139,8 @@ }, "outputs": [], "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", + " %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", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -1300,8 +1300,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -1410,8 +1410,8 @@ "metadata": {}, "outputs": [], "source": [ - "%store -r model_storage_dir repo_storage_dir\n", "try:\n", + " %store -r model_storage_dir repo_storage_dir\n", " test = [model_storage_dir, repo_storage_dir]\n", "except NameError as e:\n", " print(\"There is an issue with your variables.\")\n", @@ -1429,13 +1429,14 @@ " print(str)\n", " raise\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_dl_file = None\n", "gdrive_file_id = None\n", "\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", " 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", @@ -1466,8 +1467,8 @@ "elif gdrive_file_id is not None:\n", " %cd \"{model_storage_dir}\"\n", " gdown.download(f\"https://drive.google.com/uc?id={gdrive_file_id}&confirm=t\")\n", - "elif magnet_match: pass\n", - "else: print('Could not parse your URI.')" + "else:\n", + " print('Could not parse your URI.')" ] } ],