mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-12-23 07:36:38 +00:00
Use package.version for model version comparison
Change `--install-models` to `--force-update-models`
This commit is contained in:
parent
78713d8017
commit
94f63cedda
5 changed files with 6 additions and 4 deletions
|
@ -125,7 +125,7 @@ def get_routes_limits(default_req_limit, daily_req_limit, api_keys_db):
|
|||
def create_app(args):
|
||||
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
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ _default_options_objects = [
|
|||
'value_type': 'bool'
|
||||
},
|
||||
{
|
||||
'name': 'INSTALL_MODELS',
|
||||
'name': 'FORCE_UPDATE_MODELS',
|
||||
'default_value': False,
|
||||
'value_type': 'bool'
|
||||
},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from argostranslate import package, translate
|
||||
from packaging import version
|
||||
|
||||
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
|
||||
):
|
||||
update = True
|
||||
if pack.package_version < available_package.package_version:
|
||||
if version.parse(pack.package_version) < version.parse(available_package.package_version):
|
||||
print(
|
||||
f"Updating {available_package} ({pack.package_version}->{available_package.package_version}) ..."
|
||||
)
|
||||
|
|
|
@ -161,7 +161,7 @@ def get_args():
|
|||
"--update-models", default=DEFARGS['UPDATE_MODELS'], action="store_true", help="Update language models at startup"
|
||||
)
|
||||
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(
|
||||
"--metrics",
|
||||
|
|
|
@ -54,6 +54,7 @@ dependencies = [
|
|||
"redis ==4.3.4",
|
||||
"prometheus-client ==0.15.0",
|
||||
"polib ==1.1.1",
|
||||
"packaging ==23.1"
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
|
Loading…
Reference in a new issue