1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-11-16 20:40:10 +01:00

Use package.version for model version comparison

Change `--install-models` to `--force-update-models`
This commit is contained in:
Robert George 2023-09-29 15:31:33 -07:00
parent 78713d8017
commit 94f63cedda
No known key found for this signature in database
GPG Key ID: 9B0D835A293663C4
5 changed files with 6 additions and 4 deletions

View File

@ -125,7 +125,7 @@ def get_routes_limits(default_req_limit, daily_req_limit, api_keys_db):
def create_app(args): def create_app(args):
from libretranslate.init import boot from libretranslate.init import boot
boot(args.load_only, args.update_models, args.install_models) boot(args.load_only, args.update_models, args.force_update_models)
from libretranslate.language import load_languages from libretranslate.language import load_languages

View File

@ -172,7 +172,7 @@ _default_options_objects = [
'value_type': 'bool' 'value_type': 'bool'
}, },
{ {
'name': 'INSTALL_MODELS', 'name': 'FORCE_UPDATE_MODELS',
'default_value': False, 'default_value': False,
'value_type': 'bool' 'value_type': 'bool'
}, },

View File

@ -1,5 +1,6 @@
from argostranslate import package, translate from argostranslate import package, translate
from packaging import version
import libretranslate.language import libretranslate.language
@ -55,7 +56,7 @@ def check_and_install_models(force=False, load_only_lang_codes=None,update=False
and pack.to_code == available_package.to_code and pack.to_code == available_package.to_code
): ):
update = True update = True
if pack.package_version < available_package.package_version: if version.parse(pack.package_version) < version.parse(available_package.package_version):
print( print(
f"Updating {available_package} ({pack.package_version}->{available_package.package_version}) ..." f"Updating {available_package} ({pack.package_version}->{available_package.package_version}) ..."
) )

View File

@ -161,7 +161,7 @@ def get_args():
"--update-models", default=DEFARGS['UPDATE_MODELS'], action="store_true", help="Update language models at startup" "--update-models", default=DEFARGS['UPDATE_MODELS'], action="store_true", help="Update language models at startup"
) )
parser.add_argument( parser.add_argument(
"--install-models", default=DEFARGS['INSTALL_MODELS'], action="store_true", help="Install language models at startup" "--force-update-models", default=DEFARGS['FORCE_UPDATE_MODELS'], action="store_true", help="Install/Reinstall language models at startup"
) )
parser.add_argument( parser.add_argument(
"--metrics", "--metrics",

View File

@ -54,6 +54,7 @@ dependencies = [
"redis ==4.3.4", "redis ==4.3.4",
"prometheus-client ==0.15.0", "prometheus-client ==0.15.0",
"polib ==1.1.1", "polib ==1.1.1",
"packaging ==23.1"
] ]
[project.scripts] [project.scripts]