From 1af2610c7107426171de82d821d0631c38c4e330 Mon Sep 17 00:00:00 2001 From: Thomas Mello Date: Fri, 16 Sep 2022 12:26:01 +0300 Subject: [PATCH] Update conda environment on startup always (#1171) (#1176) * Update environment on startup always * Message to explicitly state no environment.yaml update required Co-authored-by: hlky <106811348+hlky@users.noreply.github.com> Co-authored-by: Brian Semrau Co-authored-by: hlky <106811348+hlky@users.noreply.github.com> --- update_to_latest.cmd | 39 ++++++++++++++++++++------------------- webui-streamlit.cmd | 18 ++++++++++++++++++ webui.cmd | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/update_to_latest.cmd b/update_to_latest.cmd index 8ed32e3..1fdfdeb 100644 --- a/update_to_latest.cmd +++ b/update_to_latest.cmd @@ -36,25 +36,26 @@ IF "%v_conda_path%"=="" ( echo Stashing local changes and pulling latest update... call git stash call git pull -echo If you want to restore changes you made before updating, run "git stash pop". -call "%v_conda_path%\Scripts\activate.bat" - -for /f "delims=" %%a in ('git log -1 --format^="%%H" -- environment.yaml') DO set v_cur_hash=%%a -set /p "v_last_hash="<"z_version_env.tmp" -echo %v_cur_hash%>z_version_env.tmp - -echo Current environment.yaml hash: %v_cur_hash% -echo Previous environment.yaml hash: %v_last_hash% - -if "%v_last_hash%" == "%v_cur_hash%" ( - echo environment.yaml unchanged. dependencies should be up to date. - echo if you still have unresolved dependencies, delete "z_version_env.tmp" - if not defined AUTO pause -) else ( - echo environment.yaml changed. updating dependencies - call conda env create --name "%v_conda_env_name%" -f environment.yaml - call conda env update --name "%v_conda_env_name%" -f environment.yaml - if not defined AUTO pause +set /P restore="Do you want to restore changes you made before updating? (Y/N): " +IF /I "%restore%" == "N" ( + echo Removing changes please wait... + call git stash drop + echo Changes removed, press any key to continue... + pause >nul +) ELSE IF /I "%restore%" == "Y" ( + echo Restoring changes, please wait... + call git stash pop --quiet + echo Changes restored, press any key to continue... + pause >nul ) +for /f "delims=" %%a in ('git log -1 --format^="%%H" -- environment.yaml') DO set v_cur_hash=%%a +echo %v_cur_hash%>z_version_env.tmp + +call conda env create --name "%v_conda_env_name%" -f environment.yaml +call conda env update --name "%v_conda_env_name%" -f environment.yaml +if not defined AUTO pause + +call "%v_conda_path%\Scripts\activate.bat" + ::cmd /k diff --git a/webui-streamlit.cmd b/webui-streamlit.cmd index 4bd5e48..eefd2e7 100644 --- a/webui-streamlit.cmd +++ b/webui-streamlit.cmd @@ -52,6 +52,24 @@ if not exist "z_version_env.tmp" ( call "%v_conda_path%\Scripts\activate.bat" "%v_conda_env_name%" +set v_last_hash=0 +set /p "v_last_hash="<"z_version_env.tmp" +for /f "delims=" %%a in ('git log -1 --format^="%%H" -- environment.yaml') DO set v_cur_hash=%%a + +if not "%v_last_hash%" == "%v_cur_hash%" ( + set /P updateenv="Do you want to update with the latest environment.yaml? (Y/N): " + if /I "%updateenv%" == "N" ( + echo Starting without updating dependencies. + ) else if /I "%updateenv%" == "Y" ( + echo Updating dependencies... + call conda env create --name "%v_conda_env_name%" -f environment.yaml + call conda env update --name "%v_conda_env_name%" -f environment.yaml + echo %v_cur_hash%>z_version_env.tmp + ) +) else ( + echo No environment.yaml update required. +) + :PROMPT set SETUPTOOLS_USE_DISTUTILS=stdlib IF EXIST "models\ldm\stable-diffusion-v1\model.ckpt" ( diff --git a/webui.cmd b/webui.cmd index e062f1d..dae03a7 100644 --- a/webui.cmd +++ b/webui.cmd @@ -52,6 +52,24 @@ if not exist "z_version_env.tmp" ( call "%v_conda_path%\Scripts\activate.bat" "%v_conda_env_name%" +set v_last_hash=0 +set /p "v_last_hash="<"z_version_env.tmp" +for /f "delims=" %%a in ('git log -1 --format^="%%H" -- environment.yaml') DO set v_cur_hash=%%a + +if not "%v_last_hash%" == "%v_cur_hash%" ( + set /P updateenv="Do you want to update with the latest environment.yaml? (Y/N): " + if /I "%updateenv%" == "N" ( + echo Starting without updating dependencies. + ) else if /I "%updateenv%" == "Y" ( + echo Updating dependencies... + call conda env create --name "%v_conda_env_name%" -f environment.yaml + call conda env update --name "%v_conda_env_name%" -f environment.yaml + echo %v_cur_hash%>z_version_env.tmp + ) +) else ( + echo No environment.yaml update required. +) + :PROMPT set SETUPTOOLS_USE_DISTUTILS=stdlib IF EXIST "models\ldm\stable-diffusion-v1\model.ckpt" (