Add export directory setting

This commit is contained in:
xoihazard 2023-01-03 06:25:17 +09:00
parent d5d9b82f34
commit 8594a7dbda
1 changed files with 17 additions and 9 deletions

View File

@ -71,11 +71,13 @@
"# symlink_to_notebooks = True # Enables the creation of symlinks back to /notebooks/\n",
"# model_storage_dir = '/tmp/stable-diffusion/models' # Where the models will be downloaded to.\n",
"# repo_storage_dir = '/notebooks' # Where the repository will be downloaded to.\n",
"# export_storage_dir = '/notebooks/exports' # Where the generated images will be exported to.\n",
"\n",
"# Paid Tier\n",
"# symlink_to_notebooks = False\n",
"# model_storage_dir = '/storage/models'\n",
"# repo_storage_dir = '/notebooks'\n",
"# export_storage_dir = '/notebooks/exports'\n",
"\n",
"\n",
"# Other optional settings\n",
@ -116,7 +118,7 @@
"\n",
"# ===================================================================================================\n",
"# Save variables to Jupiter's temp storage so we can access it even if the kernel restarts.\n",
"%store symlink_to_notebooks model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae download_scripts activate_deepdanbooru activate_medvram disable_pickle_check gradio_port gradio_auth search_paperspace_datasets ui_theme insecure_extension_access"
"%store symlink_to_notebooks model_storage_dir repo_storage_dir export_storage_dir activate_xformers link_novelai_anime_vae download_scripts activate_deepdanbooru activate_medvram disable_pickle_check gradio_port gradio_auth search_paperspace_datasets ui_theme insecure_extension_access"
]
},
{
@ -1191,25 +1193,31 @@
},
"outputs": [],
"source": [
"%store -r model_storage_dir repo_storage_dir\n",
"%store -r model_storage_dir repo_storage_dir export_storage_dir\n",
"try:\n",
" test = [model_storage_dir, repo_storage_dir]\n",
" test = [model_storage_dir, repo_storage_dir, export_storage_dir]\n",
"except NameError as e:\n",
" print(\"There is an issue with your variables.\")\n",
" print(\"Please go back to the first block and make sure your settings are correct, then run the cell.\")\n",
" print('Error:', e)\n",
" import sys\n",
" sys.exit(1)\n",
"\n",
"import os\n",
"\n",
"if not os.path.exists(export_storage_dir):\n",
" os.makedirs(export_storage_dir)\n",
"\n",
"!if [ $(dpkg-query -W -f='${Status}' p7zip-full 2>/dev/null | grep -c \"ok installed\") = 0 ]; then sudo apt update && sudo apt install -y p7zip-full; fi # install 7z if it isn't already installed\n",
"from datetime import datetime\n",
"datetime_str = datetime.now().strftime('%m-%d-%Y_%H:%M:%S')\n",
"%cd /notebooks/\n",
"%cd \"{export_storage_dir}\"\n",
"!mkdir -p \"{datetime_str}/log\"\n",
"!cd \"{repo_storage_dir}/stable-diffusion-webui/log/\" && mv * \"/notebooks/{datetime_str}/log\"\n",
"!cd \"{repo_storage_dir}/stable-diffusion-webui/outputs/\" && mv * \"/notebooks/{datetime_str}\"\n",
"!cd \"{repo_storage_dir}/stable-diffusion-webui/log/\" && mv * \"{datetime_str}/log\"\n",
"!cd \"{repo_storage_dir}/stable-diffusion-webui/outputs/\" && mv * \"{datetime_str}\"\n",
"!TEMP=\"/notebooks/{datetime_str}\" # find command has issues with ipynb variables??\n",
"!find \"{TEMP}\" -name .ipynb_checkpoints -exec rm -rf \"{}\" +\n",
"!7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on \"{datetime_str}.7z\" \"/notebooks/{datetime_str}/\""
"!7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on \"{datetime_str}.7z\" \"{datetime_str}/\""
]
},
{
@ -1229,8 +1237,8 @@
"metadata": {},
"outputs": [],
"source": [
"# !rm -rf \"/notebooks/{datetime_str}/\"\n",
"# !echo Deleted /notebooks/{datetime_str}/"
"# !rm -rf \"{export_storage_dir}/{datetime_str}/\"\n",
"# !echo Deleted {export_storage_dir}/{datetime_str}/"
]
},
{