(bump:minor) Feat: Add mechanism for user-site update and auto creating releases (#56)
* move flowsettings.py and launch.py to root * update docs * sync sub package versions * rename launch.py to app.py and make run scripts work with installation package * add update scripts * auto version for root package * rename authors and update doc dir * Update auto-bump-and-release.yaml to trigger on push to main branch * latest as branch instead of tag * pin deps versions * cache the changelogs
This commit is contained in:
@@ -95,11 +95,27 @@ function install_dependencies() {
|
||||
local kotaemon_root="$(pwd)/libs/kotaemon"
|
||||
local ktem_root="$(pwd)/libs/ktem/"
|
||||
|
||||
echo "" && echo "Install kotaemon's requirements"
|
||||
python -m pip install -e "$kotaemon_root"
|
||||
if [ -f "$(pwd)/VERSION" ]; then
|
||||
local app_version=$(<"$(pwd)/VERSION")
|
||||
else
|
||||
local app_version="latest"
|
||||
fi
|
||||
|
||||
echo "" && echo "Install ktem's requirements"
|
||||
python -m pip install -e "$ktem_root"
|
||||
if [ -f "pyproject.toml" ]; then
|
||||
echo "Found pyproject.toml. Installing from source"
|
||||
echo "" && echo "Installing libs/kotaemon"
|
||||
python -m pip install -e "$kotaemon_root"
|
||||
echo "" && echo "Installing libs/ktem"
|
||||
python -m pip install -e "$ktem_root"
|
||||
|
||||
python -m pip install --no-deps -e .
|
||||
else
|
||||
echo "Installing Kotaemon $app_version"
|
||||
# Work around for versioning control
|
||||
python -m pip install "git+https://github.com/Cinnamon/kotaemon.git@$app_version#subdirectory=libs/kotaemon"
|
||||
python -m pip install "git+https://github.com/Cinnamon/kotaemon.git@$app_version#subdirectory=libs/ktem"
|
||||
python -m pip install --no-deps "git+https://github.com/Cinnamon/kotaemon.git@$app_version"
|
||||
fi
|
||||
|
||||
if ! pip list 2>/dev/null | grep -q "kotaemon"; then
|
||||
echo "Installation failed. You may need to run the installer again."
|
||||
@@ -128,7 +144,7 @@ function setup_local_model() {
|
||||
}
|
||||
|
||||
function launch_ui() {
|
||||
python $(pwd)/libs/ktem/launch.py || {
|
||||
python $(pwd)/app.py || {
|
||||
echo "" && echo "Will exit now..."
|
||||
exit 1
|
||||
}
|
||||
@@ -153,20 +169,20 @@ python_version="3.10"
|
||||
|
||||
check_path_for_spaces
|
||||
|
||||
print_highlight "Setup Anaconda/Miniconda"
|
||||
print_highlight "Setting up Miniconda"
|
||||
install_miniconda
|
||||
|
||||
print_highlight "Create and Activate conda environment"
|
||||
print_highlight "Creating conda environment"
|
||||
create_conda_env "$python_version"
|
||||
activate_conda_env
|
||||
|
||||
print_highlight "Install requirements"
|
||||
print_highlight "Installing requirements"
|
||||
install_dependencies
|
||||
|
||||
print_highlight "Setting up a local model"
|
||||
setup_local_model
|
||||
|
||||
print_highlight "Launching web UI. Please wait..."
|
||||
print_highlight "Launching Kotaemon in your browser, please wait..."
|
||||
launch_ui
|
||||
|
||||
deactivate_conda_env
|
||||
|
@@ -95,11 +95,27 @@ function install_dependencies() {
|
||||
local kotaemon_root="$(pwd)/libs/kotaemon"
|
||||
local ktem_root="$(pwd)/libs/ktem/"
|
||||
|
||||
echo "" && echo "Install kotaemon's requirements"
|
||||
python -m pip install -e "$kotaemon_root"
|
||||
if [ -f "$(pwd)/VERSION" ]; then
|
||||
local app_version=$(<"$(pwd)/VERSION")
|
||||
else
|
||||
local app_version="latest"
|
||||
fi
|
||||
|
||||
echo "" && echo "Install ktem's requirements"
|
||||
python -m pip install -e "$ktem_root"
|
||||
if [ -f "pyproject.toml" ]; then
|
||||
echo "Found pyproject.toml. Installing from source"
|
||||
echo "" && echo "Installing libs/kotaemon"
|
||||
python -m pip install -e "$kotaemon_root"
|
||||
echo "" && echo "Installing libs/ktem"
|
||||
python -m pip install -e "$ktem_root"
|
||||
|
||||
python -m pip install --no-deps -e .
|
||||
else
|
||||
echo "Installing Kotaemon $app_version"
|
||||
# Work around for versioning control
|
||||
python -m pip install "git+https://github.com/Cinnamon/kotaemon.git@$app_version#subdirectory=libs/kotaemon"
|
||||
python -m pip install "git+https://github.com/Cinnamon/kotaemon.git@$app_version#subdirectory=libs/ktem"
|
||||
python -m pip install --no-deps "git+https://github.com/Cinnamon/kotaemon.git@$app_version"
|
||||
fi
|
||||
|
||||
if ! pip list 2>/dev/null | grep -q "kotaemon"; then
|
||||
echo "Installation failed. You may need to run the installer again."
|
||||
@@ -129,7 +145,7 @@ function setup_local_model() {
|
||||
}
|
||||
|
||||
function launch_ui() {
|
||||
python $(pwd)/libs/ktem/launch.py || {
|
||||
python $(pwd)/app.py || {
|
||||
echo "" && echo "Will exit now..."
|
||||
exit 1
|
||||
}
|
||||
@@ -157,20 +173,20 @@ python_version="3.10"
|
||||
|
||||
check_path_for_spaces
|
||||
|
||||
print_highlight "Setup Anaconda/Miniconda"
|
||||
print_highlight "Setting up Miniconda"
|
||||
install_miniconda
|
||||
|
||||
print_highlight "Create and Activate conda environment"
|
||||
print_highlight "Creating conda environment"
|
||||
create_conda_env "$python_version"
|
||||
activate_conda_env
|
||||
|
||||
print_highlight "Install requirements"
|
||||
print_highlight "Installing requirements"
|
||||
install_dependencies
|
||||
|
||||
print_highlight "Setting up a local model"
|
||||
setup_local_model
|
||||
|
||||
print_highlight "Launching web UI. Please wait..."
|
||||
print_highlight "Launching Kotaemon in your browser, please wait..."
|
||||
launch_ui
|
||||
|
||||
deactivate_conda_env
|
||||
|
@@ -3,6 +3,7 @@
|
||||
:: Main script execution
|
||||
CD /D "%~dp0\.."
|
||||
|
||||
SET /p app_version=<"%CD%\VERSION" || SET app_version=latest
|
||||
SET install_dir=%CD%\install_dir
|
||||
SET conda_root=%install_dir%\conda
|
||||
SET env_dir=%install_dir%\env
|
||||
@@ -15,19 +16,19 @@ IF %ERRORLEVEL% EQU 0 (
|
||||
GOTO :end
|
||||
)
|
||||
|
||||
CALL :print_highlight "Setup Anaconda/Miniconda"
|
||||
CALL :print_highlight "Setting up Miniconda"
|
||||
CALL :download_and_install_miniconda
|
||||
:: check if function run fail, then exit the script
|
||||
IF ERRORLEVEL 1 GOTO :end
|
||||
|
||||
CALL :print_highlight "Create and Activate conda environment"
|
||||
CALL :print_highlight "Creating conda environment"
|
||||
CALL :create_conda_environment
|
||||
IF ERRORLEVEL 1 GOTO :end
|
||||
|
||||
CALL :activate_environment
|
||||
IF ERRORLEVEL 1 GOTO :end
|
||||
|
||||
CALL :print_highlight "Install requirements"
|
||||
CALL :print_highlight "Installing Kotaemon"
|
||||
CALL :install_dependencies
|
||||
IF ERRORLEVEL 1 GOTO :end
|
||||
|
||||
@@ -35,7 +36,7 @@ CALL :print_highlight "Setting up a local model"
|
||||
CALL :setup_local_model
|
||||
IF ERRORLEVEL 1 GOTO :end
|
||||
|
||||
CALL :print_highlight "Launching web UI. Please wait..."
|
||||
CALL :print_highlight "Launching Kotaemon in your browser, please wait..."
|
||||
CALL :launch_ui
|
||||
|
||||
CALL :deactivate_environment
|
||||
@@ -113,11 +114,23 @@ pip list | findstr /C:"kotaemon" >NUL 2>&1
|
||||
IF %ERRORLEVEL% == 0 (
|
||||
ECHO Dependencies are already installed
|
||||
) ELSE (
|
||||
ECHO Install kotaemon's requirements
|
||||
CALL python -m pip install -e "%CD%\libs\kotaemon"
|
||||
IF EXIST "pyproject.toml" (
|
||||
ECHO Found pyproject.toml. Installing from source...
|
||||
|
||||
ECHO Install ktem's requirements
|
||||
CALL python -m pip install -e "%CD%\libs\ktem"
|
||||
ECHO Installing libs\kotaemon
|
||||
python -m pip install -e "%CD%\libs\kotaemon"
|
||||
|
||||
ECHO Installing libs\ktem
|
||||
python -m pip install -e "%CD%\libs\ktem"
|
||||
|
||||
python -m pip install --no-deps -e .
|
||||
) ELSE (
|
||||
ECHO Installing Kotaemon %app_version%
|
||||
@REM Work around for versioning control
|
||||
python -m pip install git+https://github.com/Cinnamon/kotaemon.git@"%app_version%"#subdirectory=libs/kotaemon
|
||||
python -m pip install git+https://github.com/Cinnamon/kotaemon.git@"%app_version%"#subdirectory=libs/ktem
|
||||
python -m pip install --no-deps git+https://github.com/Cinnamon/kotaemon.git@"%app_version%"
|
||||
)
|
||||
|
||||
( CALL pip list | findstr /C:"kotaemon" >NUL 2>&1 ) || (
|
||||
ECHO. && ECHO Installation failed. You may need to run the installer again.
|
||||
@@ -126,8 +139,8 @@ IF %ERRORLEVEL% == 0 (
|
||||
)
|
||||
|
||||
CALL :print_highlight "Install successfully. Clear cache..."
|
||||
CALL "%conda_root%\condabin\conda.bat" clean --all -y
|
||||
CALL python -m pip cache purge
|
||||
"%conda_root%\condabin\conda.bat" clean --all -y
|
||||
python -m pip cache purge
|
||||
)
|
||||
GOTO :eof
|
||||
|
||||
@@ -136,7 +149,7 @@ python "%CD%\scripts\serve_local.py"
|
||||
GOTO :eof
|
||||
|
||||
:launch_ui
|
||||
CALL python "%CD%\libs\ktem\launch.py" || ( ECHO. && ECHO Will exit now... && GOTO :exit_func_with_error )
|
||||
CALL python "%CD%\app.py" || ( ECHO. && ECHO Will exit now... && GOTO :exit_func_with_error )
|
||||
GOTO :eof
|
||||
|
||||
:print_highlight
|
||||
|
87
scripts/update_linux.sh
Normal file
87
scripts/update_linux.sh
Normal file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
# functions for better code organization
|
||||
function check_path_for_spaces() {
|
||||
if [[ $PWD =~ \ ]]; then
|
||||
echo "The current workdir has whitespace which can lead to unintended behaviour. Please modify your path and continue later."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function activate_conda_env() {
|
||||
# deactivate the current env(s) to avoid conflicts
|
||||
{ conda deactivate && conda deactivate && conda deactivate; } 2>/dev/null
|
||||
|
||||
# check if conda env is broken (because of interruption during creation)
|
||||
if [ ! -f "$env_dir/bin/python" ]; then
|
||||
echo "Conda environment appears to be broken. You may need to remove $env_dir and run the installer again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "$conda_root/etc/profile.d/conda.sh" # conda init
|
||||
conda activate "$env_dir" || {
|
||||
echo "Failed to activate environment. Please remove $env_dir and run the installer again"
|
||||
exit 1
|
||||
}
|
||||
echo "Activate conda environment at $CONDA_PREFIX"
|
||||
}
|
||||
|
||||
function deactivate_conda_env() {
|
||||
# Conda deactivate if we are in the right env
|
||||
if [ "$CONDA_PREFIX" == "$env_dir" ]; then
|
||||
conda deactivate
|
||||
echo "Deactivate conda environment at $env_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
function update_latest() {
|
||||
current_version=$(pip list | awk '/kotaemon-app/ {print $2}')
|
||||
echo "Current version $current_version"
|
||||
|
||||
if [ -f "pyproject.toml" ]; then
|
||||
echo "Source files detected. Please perform git pull manually."
|
||||
deactivate_environment
|
||||
exit 1
|
||||
else
|
||||
echo "Installing version: $app_version"
|
||||
# Work around for versioning control
|
||||
python -m pip install "git+https://github.com/Cinnamon/kotaemon.git@$app_version#subdirectory=libs/kotaemon"
|
||||
python -m pip install "git+https://github.com/Cinnamon/kotaemon.git@$app_version#subdirectory=libs/ktem"
|
||||
python -m pip install --no-deps git+https://github.com/Cinnamon/kotaemon.git@$app_version
|
||||
if [ $? -ne 0 ]; then
|
||||
echo
|
||||
echo "Update failed. You may need to run the update again."
|
||||
deactivate_environment
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function print_highlight() {
|
||||
local message="${1}"
|
||||
echo "" && echo "******************************************************"
|
||||
echo $message
|
||||
echo "******************************************************" && echo ""
|
||||
}
|
||||
|
||||
# Main script execution
|
||||
|
||||
# move two levels up from the dir where this script resides
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" && cd ..
|
||||
|
||||
app_version="latest"
|
||||
install_dir="$(pwd)/install_dir"
|
||||
conda_root="${install_dir}/conda"
|
||||
env_dir="${install_dir}/env"
|
||||
|
||||
check_path_for_spaces
|
||||
|
||||
print_highlight "Activating conda environment"
|
||||
activate_conda_env
|
||||
|
||||
print_highlight "Updating Kotaemon to latest"
|
||||
update_latest
|
||||
|
||||
deactivate_conda_env
|
||||
|
||||
read -p "Press enter to continue"
|
87
scripts/update_macos.sh
Normal file
87
scripts/update_macos.sh
Normal file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
# functions for better code organization
|
||||
function check_path_for_spaces() {
|
||||
if [[ $PWD =~ \ ]]; then
|
||||
echo "The current workdir has whitespace which can lead to unintended behaviour. Please modify your path and continue later."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function activate_conda_env() {
|
||||
# deactivate the current env(s) to avoid conflicts
|
||||
{ conda deactivate && conda deactivate && conda deactivate; } 2>/dev/null
|
||||
|
||||
# check if conda env is broken (because of interruption during creation)
|
||||
if [ ! -f "$env_dir/bin/python" ]; then
|
||||
echo "Conda environment appears to be broken. You may need to remove $env_dir and run the installer again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "$conda_root/etc/profile.d/conda.sh" # conda init
|
||||
conda activate "$env_dir" || {
|
||||
echo "Failed to activate environment. Please remove $env_dir and run the installer again"
|
||||
exit 1
|
||||
}
|
||||
echo "Activate conda environment at $CONDA_PREFIX"
|
||||
}
|
||||
|
||||
function deactivate_conda_env() {
|
||||
# Conda deactivate if we are in the right env
|
||||
if [ "$CONDA_PREFIX" == "$env_dir" ]; then
|
||||
conda deactivate
|
||||
echo "Deactivate conda environment at $env_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
function update_latest() {
|
||||
current_version=$(pip list | awk '/kotaemon-app/ {print $2}')
|
||||
echo "Current version $current_version"
|
||||
|
||||
if [ -f "pyproject.toml" ]; then
|
||||
echo "Source files detected. Please perform git pull manually."
|
||||
deactivate_environment
|
||||
exit 1
|
||||
else
|
||||
echo "Installing version: $app_version"
|
||||
# Work around for versioning control
|
||||
python -m pip install "git+https://github.com/Cinnamon/kotaemon.git@$app_version#subdirectory=libs/kotaemon"
|
||||
python -m pip install "git+https://github.com/Cinnamon/kotaemon.git@$app_version#subdirectory=libs/ktem"
|
||||
python -m pip install --no-deps git+https://github.com/Cinnamon/kotaemon.git@$app_version
|
||||
if [ $? -ne 0 ]; then
|
||||
echo
|
||||
echo "Update failed. You may need to run the update again."
|
||||
deactivate_environment
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function print_highlight() {
|
||||
local message="${1}"
|
||||
echo "" && echo "******************************************************"
|
||||
echo $message
|
||||
echo "******************************************************" && echo ""
|
||||
}
|
||||
|
||||
# Main script execution
|
||||
|
||||
# move two levels up from the dir where this script resides
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" && cd ..
|
||||
|
||||
app_version="latest"
|
||||
install_dir="$(pwd)/install_dir"
|
||||
conda_root="${install_dir}/conda"
|
||||
env_dir="${install_dir}/env"
|
||||
|
||||
check_path_for_spaces
|
||||
|
||||
print_highlight "Activating conda environment"
|
||||
activate_conda_env
|
||||
|
||||
print_highlight "Updating Kotaemon to latest"
|
||||
update_latest
|
||||
|
||||
deactivate_conda_env
|
||||
|
||||
read -p "Press enter to continue"
|
99
scripts/update_windows.bat
Normal file
99
scripts/update_windows.bat
Normal file
@@ -0,0 +1,99 @@
|
||||
@ECHO off
|
||||
|
||||
:: Main script execution
|
||||
CD /D "%~dp0\.."
|
||||
|
||||
SET app_version=latest
|
||||
SET install_dir=%CD%\install_dir
|
||||
SET conda_root=%install_dir%\conda
|
||||
SET env_dir=%install_dir%\env
|
||||
|
||||
ECHO %CD%| FINDSTR /C:" " >nul 2>&1
|
||||
IF %ERRORLEVEL% EQU 0 (
|
||||
ECHO The current workdir has whitespace which can lead to unintended behaviour. Please modify your path and continue later.
|
||||
GOTO :end
|
||||
)
|
||||
|
||||
CALL :print_highlight "Activating conda environment"
|
||||
CALL :activate_environment
|
||||
IF ERRORLEVEL 1 GOTO :end
|
||||
|
||||
CALL :print_highlight "Updating Kotaemon to latest"
|
||||
CALL :update_latest
|
||||
IF ERRORLEVEL 1 GOTO :end
|
||||
|
||||
CALL :deactivate_environment
|
||||
GOTO :end_success
|
||||
|
||||
|
||||
:activate_environment
|
||||
:: deactivate existing conda env(s) to avoid conflicts
|
||||
( CALL conda deactivate && CALL conda deactivate && CALL conda deactivate ) 2> nul
|
||||
|
||||
CALL "%env_dir%\python.exe" --version >nul 2>&1 || (
|
||||
ECHO The environment appears to be broken. You may need to remove %env_dir% and run the installer again.
|
||||
GOTO :exit_func_with_error
|
||||
)
|
||||
|
||||
CALL "%conda_root%\condabin\conda.bat" activate %env_dir% || (
|
||||
ECHO Failed to activate environment. You may need to remove %env_dir% and run the installer again.
|
||||
GOTO :exit_func_with_error
|
||||
)
|
||||
ECHO Activate conda environment at %env_dir%
|
||||
|
||||
GOTO :eof
|
||||
|
||||
:deactivate_environment
|
||||
:: Conda deactivate if we are in the right env
|
||||
IF "%CONDA_PREFIX%" == "%env_dir%" (
|
||||
CALL "%conda_root%\condabin\conda.bat" deactivate
|
||||
ECHO Deactivate conda environment at %env_dir%
|
||||
)
|
||||
GOTO :eof
|
||||
|
||||
:update_latest
|
||||
FOR /F "tokens=1,2" %%a in ('pip list') do if "%%a"=="kotaemon-app" set current_version=%%b
|
||||
ECHO Current version %current_version%
|
||||
|
||||
IF EXIST "pyproject.toml" (
|
||||
ECHO Source files detected. Please perform git pull manually.
|
||||
CALL :deactivate_environment
|
||||
GOTO :exit_func_with_error
|
||||
) ELSE (
|
||||
ECHO Installing version: %app_version%
|
||||
@REM Work around for versioning control
|
||||
python -m pip install git+https://github.com/Cinnamon/kotaemon.git@"%app_version%"#subdirectory=libs/kotaemon
|
||||
python -m pip install git+https://github.com/Cinnamon/kotaemon.git@"%app_version%"#subdirectory=libs/ktem
|
||||
python -m pip install --no-deps git+https://github.com/Cinnamon/kotaemon.git@"%app_version%"
|
||||
) || (
|
||||
ECHO. && ECHO Update failed. You may need to run the update again.
|
||||
CALL :deactivate_environment
|
||||
GOTO :exit_func_with_error
|
||||
)
|
||||
|
||||
CALL :print_highlight "Update successfully."
|
||||
FOR /F "tokens=1,2" %%a in ('pip list') do if "%%a"=="kotaemon-app" set updated_version=%%b
|
||||
ECHO Updated version %updated_version%
|
||||
ECHO %updated_version% > VERSION
|
||||
GOTO :eof
|
||||
|
||||
:print_highlight
|
||||
ECHO. && ECHO ******************************************************
|
||||
ECHO %~1
|
||||
ECHO ****************************************************** && ECHO.
|
||||
GOTO :eof
|
||||
|
||||
:exit_func_with_error
|
||||
:: Called inside functions when error happens, then back to the main routine with error code 1
|
||||
EXIT /B 1
|
||||
|
||||
:end_success
|
||||
:: Exit the script main routine with error code 0 (success)
|
||||
ECHO Script completed successfully.
|
||||
PAUSE
|
||||
EXIT /B 0
|
||||
|
||||
:end
|
||||
:: Exit the script main routine with error code 1 (fail)
|
||||
PAUSE
|
||||
EXIT /B 1
|
Reference in New Issue
Block a user