From 0d2cf9ac186fc87cc56fce2a4e1136aca2386252 Mon Sep 17 00:00:00 2001 From: yedpodtrzitko Date: Wed, 29 Mar 2023 16:35:37 +0700 Subject: feat: use existing virtualenv if already active --- webui.sh | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 8cdad22d..0d25be2e 100755 --- a/webui.sh +++ b/webui.sh @@ -152,24 +152,31 @@ else cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } fi -printf "\n%s\n" "${delimiter}" -printf "Create and activate python venv" -printf "\n%s\n" "${delimiter}" -cd "${install_dir}"/"${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } -if [[ ! -d "${venv_dir}" ]] -then - "${python_cmd}" -m venv "${venv_dir}" - first_launch=1 -fi -# shellcheck source=/dev/null -if [[ -f "${venv_dir}"/bin/activate ]] +if [[ -z "${VIRTUAL_ENV}" ]]; then - source "${venv_dir}"/bin/activate + printf "\n%s\n" "${delimiter}" + printf "Create and activate python venv" + printf "\n%s\n" "${delimiter}" + cd "${install_dir}"/"${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } + if [[ ! -d "${venv_dir}" ]] + then + "${python_cmd}" -m venv "${venv_dir}" + first_launch=1 + fi + # shellcheck source=/dev/null + if [[ -f "${venv_dir}"/bin/activate ]] + then + source "${venv_dir}"/bin/activate + else + printf "\n%s\n" "${delimiter}" + printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m" + printf "\n%s\n" "${delimiter}" + exit 1 + fi else printf "\n%s\n" "${delimiter}" - printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m" + printf "python venv already activate: ${VIRTUAL_ENV}" printf "\n%s\n" "${delimiter}" - exit 1 fi if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v accelerate)" ] -- cgit v1.2.3 From b2f6e0704e178f64881f507f3a48ff36e63e1a62 Mon Sep 17 00:00:00 2001 From: catalpaaa Date: Tue, 25 Apr 2023 07:27:24 -0700 Subject: add subpath support --- modules/cmd_args.py | 1 + webui.py | 5 +++++ webui.sh | 0 3 files changed, 6 insertions(+) mode change 100755 => 100644 webui.sh (limited to 'webui.sh') diff --git a/modules/cmd_args.py b/modules/cmd_args.py index 81c0b82a..bdf106bf 100644 --- a/modules/cmd_args.py +++ b/modules/cmd_args.py @@ -101,3 +101,4 @@ parser.add_argument("--no-gradio-queue", action='store_true', help="Disables gra parser.add_argument("--skip-version-check", action='store_true', help="Do not check versions of torch and xformers") parser.add_argument("--no-hashing", action='store_true', help="disable sha256 hashing of checkpoints to help loading performance", default=False) parser.add_argument("--no-download-sd-model", action='store_true', help="don't download SD1.5 model even if no model is found in --ckpt-dir", default=False) +parser.add_argument('--subpath', type=str, help='customize the subpath for gradio, use with reverse proxy') \ No newline at end of file diff --git a/webui.py b/webui.py index b570895f..d8997819 100644 --- a/webui.py +++ b/webui.py @@ -290,6 +290,11 @@ def webui(): print(f"Startup time: {startup_timer.summary()}.") + if cmd_opts.subpath: + redirector = FastAPI() + redirector.get("/") + mounted_app = gradio.mount_gradio_app(redirector, shared.demo, path=f"/{cmd_opts.subpath}") + wait_on_server(shared.demo) print('Restarting UI...') diff --git a/webui.sh b/webui.sh old mode 100755 new mode 100644 -- cgit v1.2.3 From 14b70aa97ba356691254055a67b9eb2ec3440b3e Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Tue, 2 May 2023 11:03:11 +0300 Subject: revert unwanted change from #9865 --- webui.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 webui.sh (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh old mode 100644 new mode 100755 -- cgit v1.2.3