From dc05a95e32d5e86f577aa31b472c80202761438a Mon Sep 17 00:00:00 2001 From: lotigara <105482918+lotigara@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:26:56 +0300 Subject: [PATCH] Add a setting for installing additional languages and comments with warnings. --- manifest.toml | 7 +++++++ scripts/install | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/manifest.toml b/manifest.toml index 3b85f74..21249fd 100644 --- a/manifest.toml +++ b/manifest.toml @@ -34,6 +34,13 @@ ram.runtime = "50M" type = "group" default = "visitors" + [install.additional_languages] + ask.en = "Do install additional language models? WARNING: It will take ~6 GB of your free space." + help.en = "By default, installed models are English->French and French->English." + yes = "true" + no = "false" + type = "boolean" + [resources] [resources.sources] diff --git a/scripts/install b/scripts/install index b5fd383..c0c5421 100755 --- a/scripts/install +++ b/scripts/install @@ -28,12 +28,20 @@ pushd $install_dir source $install_dir/venv/bin/activate ynh_exec_warn_less pip install libretranslate=="$(ynh_app_upstream_version)" toml - # Install additional languages (FIXME!!!) - venv/bin/libretranslate --update-models & - export LT-PID="$!" - if [ ss -tulpen | grep '127.0.0.1:5000' ] ; then - kill -INT "$!" - fi + # WARNING!!! CODE BELOW WASN'T TESTED!!! RUN IN DEBUG MODE FROM SHELL!!! + # Checking if additional_languages was enabled... + if [ "$additional_languages" = true ] ; then + + # ...if yes, download models... + venv/bin/libretranslate --update-models & + + # ...and then kill the libretranslate process + # because it was started after downloading models! + export LT-PID="$!" + if ss -tulpen | grep '127.0.0.1:5000' ; then + kill -INT "$LT_PID" + fi + fi popd #=================================================