mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-21 23:41:01 +00:00
Named volume for db, --update-models arg
This commit is contained in:
parent
5285697203
commit
959f4638cc
6 changed files with 20 additions and 18 deletions
|
@ -130,8 +130,8 @@ Then open a web browser to http://localhost:5000
|
|||
|
||||
### Run with Docker
|
||||
|
||||
Linux/MacOS: `./lt.sh`
|
||||
Windows: double-click `lt.bat`
|
||||
Linux/MacOS: `./lt.sh [args]`
|
||||
Windows: `lt.bat [args]`
|
||||
|
||||
Then open a web browser to http://localhost:5000
|
||||
|
||||
|
@ -195,6 +195,7 @@ docker-compose -f docker-compose.cuda.yml up -d --build
|
|||
| --suggestions | Allow user suggestions | `false` | LT_SUGGESTIONS |
|
||||
| --disable-files-translation | Disable files translation | `false` | LT_DISABLE_FILES_TRANSLATION |
|
||||
| --disable-web-ui | Disable web ui | `false` | LT_DISABLE_WEB_UI |
|
||||
| --update-models | Update models at startup | `false` | LT_UPDATE_MODELS |
|
||||
|
||||
Note that each argument has an equivalent environment variable that can be used instead. The env. variables overwrite the default values but have lower priority than the command arguments and are particularly useful if used with Docker. The environment variable names are the upper-snake-case of the equivalent command argument's name with a `LT` prefix.
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ def get_routes_limits(default_req_limit, daily_req_limit, api_keys_db):
|
|||
def create_app(args):
|
||||
from app.init import boot
|
||||
|
||||
boot(args.load_only)
|
||||
boot(args.load_only, args.update_models)
|
||||
|
||||
from app.language import load_languages
|
||||
|
||||
|
|
|
@ -156,6 +156,11 @@ _default_options_objects = [
|
|||
'default_value': False,
|
||||
'value_type': 'bool'
|
||||
},
|
||||
{
|
||||
'name': 'UPDATE_MODELS',
|
||||
'default_value': False,
|
||||
'value_type': 'bool'
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ from argostranslate import package, translate
|
|||
import app.language
|
||||
|
||||
|
||||
def boot(load_only=None):
|
||||
def boot(load_only=None, update_models=False):
|
||||
try:
|
||||
check_and_install_models(load_only_lang_codes=load_only)
|
||||
check_and_install_models(force=update_models, load_only_lang_codes=load_only)
|
||||
except Exception as e:
|
||||
print("Cannot update models (normal if you're offline): %s" % str(e))
|
||||
|
||||
|
|
|
@ -144,7 +144,9 @@ def get_args():
|
|||
parser.add_argument(
|
||||
"--disable-web-ui", default=DEFARGS['DISABLE_WEB_UI'], action="store_true", help="Disable web ui"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--update-models", default=DEFARGS['UPDATE_MODELS'], action="store_true", help="Update language models at startup"
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
|
18
lt.sh
18
lt.sh
|
@ -14,17 +14,6 @@ case $uname in
|
|||
;;
|
||||
esac
|
||||
|
||||
if [[ $platform = "Windows" ]]; then
|
||||
export COMPOSE_CONVERT_WINDOWS_PATHS=1
|
||||
fi
|
||||
|
||||
# define realpath replacement function
|
||||
if [[ $platform = "MacOS / OSX" ]]; then
|
||||
realpath() {
|
||||
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
|
||||
}
|
||||
fi
|
||||
|
||||
usage(){
|
||||
echo "Usage: $0 [--port N]"
|
||||
echo
|
||||
|
@ -53,6 +42,11 @@ case $key in
|
|||
ARGS+=("$1")
|
||||
shift # past argument
|
||||
;;
|
||||
--api-keys)
|
||||
export DB_VOLUME="-v lt-db:/app/db"
|
||||
ARGS+=("$1")
|
||||
shift # past argument
|
||||
;;
|
||||
--help)
|
||||
usage
|
||||
;;
|
||||
|
@ -92,4 +86,4 @@ environment_check(){
|
|||
}
|
||||
|
||||
environment_check
|
||||
docker run -ti --rm --entrypoint bash -p $LT_PORT:$LT_PORT -v lt-share:/home/libretranslate/.local/share libretranslate/libretranslate #${ARGS[@]}
|
||||
docker run -ti --rm -p $LT_PORT:$LT_PORT $DB_VOLUME -v lt-local:/home/libretranslate/.local libretranslate/libretranslate ${ARGS[@]}
|
Loading…
Reference in a new issue