Skip to content

Commit

Permalink
Place poetry inside a env, symlink lm env
Browse files Browse the repository at this point in the history
  • Loading branch information
nsg committed Jun 22, 2023
1 parent ffdc6fb commit b4e321d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
5 changes: 2 additions & 3 deletions parts/machine-learning/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ build:

install:
mkdir -p ${SNAPCRAFT_PART_INSTALL}/usr/src/ml
mkdir -p ${SNAPCRAFT_PART_INSTALL}/opt
mkdir -p ${SNAPCRAFT_PART_INSTALL}/venv
mkdir -p ${SNAPCRAFT_PART_INSTALL}/opt/venv
cp -r immich/machine-learning/app ${SNAPCRAFT_PART_INSTALL}/usr/src/ml
cp -r /venv/ml ${SNAPCRAFT_PART_INSTALL}/venv
cp -r /opt/venv/ml ${SNAPCRAFT_PART_INSTALL}/opt/venv
19 changes: 10 additions & 9 deletions parts/machine-learning/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

VERSION="$1"
PYTHON_PART_INSTALL_BIN="${PWD}/../../python/install/usr/local/bin"
PATH="${PYTHON_PART_INSTALL_BIN}:${PATH}"

mkdir -p /venv/
mkdir -p /opt/venv/

python() {
$PYTHON_PART_INSTALL_BIN/python3 $@
Expand All @@ -15,15 +14,17 @@ pip() {
}

[ -d immich ] || git clone --branch $VERSION https://github.com/immich-app/immich.git
[ -d "/venv/ml" ] || python -m venv "/venv/ml"
[ -d "/opt/venv/ml" ] || python -m venv "/opt/venv/ml"
[ -d "/opt/venv/poetry" ] || python -m venv "/opt/venv/poetry"

pip install poetry
/opt/venv/poetry/bin/python --version
/opt/venv/poetry/bin/pip install poetry

# Configure Poetry and install dependencies
cd immich/machine-learning

export VIRTUAL_ENV="/venv/ml"

poetry config installer.max-workers 10
poetry config virtualenvs.create false
poetry install --sync --no-interaction --no-ansi --no-root --only main
export VIRTUAL_ENV="/opt/venv/ml"
/opt/venv/poetry/bin/poetry config installer.max-workers 10
/opt/venv/poetry/bin/poetry config virtualenvs.create false
/opt/venv/poetry/bin/poetry install --sync --no-interaction --no-ansi --no-root --only main
unset VIRTUAL_ENV
4 changes: 2 additions & 2 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ layout:
symlink: $SNAP_COMMON/upload
$SNAP/usr/src/ml/upload:
symlink: $SNAP_COMMON/upload
/venv/ml:
symlink: $SNAP/venv/ml
/opt/venv/ml:
symlink: $SNAP/opt/venv/ml

apps:
psql:
Expand Down

0 comments on commit b4e321d

Please sign in to comment.