From 3314b7d7952734ca45c6c87aad40806e9760cf27 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:03:56 -0700 Subject: [PATCH] Allow start scripts to have command-line flags --- CMD_FLAGS.txt | 1 - start_linux.sh | 2 +- start_macos.sh | 2 +- start_windows.bat | 2 +- start_wsl.bat | 2 +- webui.py | 5 +++-- wsl.sh | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMD_FLAGS.txt b/CMD_FLAGS.txt index 47fe8405..e69de29b 100644 --- a/CMD_FLAGS.txt +++ b/CMD_FLAGS.txt @@ -1 +0,0 @@ ---listen diff --git a/start_linux.sh b/start_linux.sh index 1de8ccdf..6792902a 100755 --- a/start_linux.sh +++ b/start_linux.sh @@ -64,4 +64,4 @@ source "$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh" # otherwise conda complains a conda activate "$INSTALL_ENV_DIR" # setup installer env -python webui.py +python webui.py $@ diff --git a/start_macos.sh b/start_macos.sh index 131a8af5..5f5bb439 100755 --- a/start_macos.sh +++ b/start_macos.sh @@ -64,4 +64,4 @@ source "$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh" # otherwise conda complains a conda activate "$INSTALL_ENV_DIR" # setup installer env -python webui.py +python webui.py $@ diff --git a/start_windows.bat b/start_windows.bat index 3140f70f..77ba93bf 100755 --- a/start_windows.bat +++ b/start_windows.bat @@ -67,7 +67,7 @@ set "CUDA_HOME=%CUDA_PATH%" call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end ) @rem setup installer env -call python webui.py +call python webui.py %* @rem below are functions for the script next line skips these during normal execution goto end diff --git a/start_wsl.bat b/start_wsl.bat index 41fa572f..26d2f8a6 100755 --- a/start_wsl.bat +++ b/start_wsl.bat @@ -5,7 +5,7 @@ cd /D "%~dp0" set PATH=%PATH%;%SystemRoot%\system32 @rem sed -i 's/\x0D$//' ./wsl.sh converts newlines to unix format in the wsl script -call wsl -e bash -lic "sed -i 's/\x0D$//' ./wsl.sh; source ./wsl.sh" +call wsl -e bash -lic "sed -i 's/\x0D$//' ./wsl.sh; source ./wsl.sh $@" :end pause diff --git a/webui.py b/webui.py index 4225cd7e..9d2fbaf1 100644 --- a/webui.py +++ b/webui.py @@ -245,7 +245,8 @@ def download_model(): def launch_webui(): - run_cmd(f"python server.py {CMD_FLAGS}", environment=True) + flags = [flag for flag in sys.argv[1:] if flag != '--update'] + run_cmd(f"python server.py {' '.join(flags)} {CMD_FLAGS}", environment=True) if __name__ == "__main__": @@ -254,7 +255,7 @@ if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--update', action='store_true', help='Update the web UI.') - args = parser.parse_args() + args, _ = parser.parse_known_args() if args.update: update_dependencies() diff --git a/wsl.sh b/wsl.sh index 6660bc2e..6b62adca 100755 --- a/wsl.sh +++ b/wsl.sh @@ -106,5 +106,5 @@ fi # setup installer env update env if called with 'wsl.sh update' case "$1" in ("update") python webui.py --update;; -(*) python webui.py;; +(*) python webui.py $@;; esac