Skip to content

Commit

Permalink
fix: update app version resolver in flowsettings (#180) (bump:patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
taprosoft authored Sep 2, 2024
1 parent 4d5f9ba commit 35b2927
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions flowsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
# change this if your app use a different name
KH_PACKAGE_NAME = "kotaemon_app"

KH_APP_VERSION = config("KH_APP_VERSION", "local")
KH_APP_VERSION = config("KH_APP_VERSION", None)
if not KH_APP_VERSION:
try:
# Caution: This might produce the wrong version
# https://stackoverflow.com/a/59533071
KH_APP_VERSION = version(KH_PACKAGE_NAME)
except Exception as e:
print(f"Failed to get app version: {e}")
except Exception:
KH_APP_VERSION = "local"

# App can be ran from anywhere and it's not trivial to decide where to store app data.
# So let's use the same directory as the flowsetting.py file.
Expand Down
4 changes: 3 additions & 1 deletion libs/ktem/ktem/assets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
from decouple import config

PDFJS_VERSION_DIST: str = config("PDFJS_VERSION_DIST", "pdfjs-4.0.379-dist")
PDFJS_PREBUILT_DIR: Path = Path(__file__).parent / "prebuilt" / PDFJS_VERSION_DIST
PDFJS_PREBUILT_DIR: Path = config(
"PDFJS_PREBUILT_DIR", Path(__file__).parent / "prebuilt" / PDFJS_VERSION_DIST
)
5 changes: 3 additions & 2 deletions scripts/run_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ function download_and_unzip() {
}

function launch_ui() {
python $(pwd)/app.py || {
local pdfjs_prebuilt_dir=$1
PDFJS_PREBUILT_DIR="$pdfjs_prebuilt_dir" python $(pwd)/app.py || {
echo "" && echo "Will exit now..."
exit 1
}
Expand Down Expand Up @@ -217,7 +218,7 @@ print_highlight "Setting up a local model"
setup_local_model

print_highlight "Launching Kotaemon in your browser, please wait..."
launch_ui
launch_ui $target_pdf_js_dir

deactivate_conda_env

Expand Down
7 changes: 4 additions & 3 deletions scripts/run_macos.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Functions for better code organization
# 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."
Expand Down Expand Up @@ -171,7 +171,8 @@ function download_and_unzip() {
}

function launch_ui() {
python $(pwd)/app.py || {
local pdfjs_prebuilt_dir=$1
PDFJS_PREBUILT_DIR="$pdfjs_prebuilt_dir" python $(pwd)/app.py || {
echo "" && echo "Will exit now..."
exit 1
}
Expand Down Expand Up @@ -221,7 +222,7 @@ print_highlight "Setting up a local model"
setup_local_model

print_highlight "Launching Kotaemon in your browser, please wait..."
launch_ui
launch_ui $target_pdf_js_dir

deactivate_conda_env

Expand Down

0 comments on commit 35b2927

Please sign in to comment.