Skip to content

Commit

Permalink
Merge branch 'master' into add-functional-test
Browse files Browse the repository at this point in the history
  • Loading branch information
bryan-brancotte committed Jan 23, 2024
2 parents 9e4b680 + 3767678 commit 39dc849
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions defense_finder_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def cli():

@cli.command()
@click.option('--models-dir', 'models_dir', required=False, help='Specify a directory containing your models.')
def update(models_dir=None):
@click.option('--force-reinstall', '-f', 'force_reinstall', is_flag=True,
help='Force update even if models in already there.', default=False)
def update(models_dir=None, force_reinstall: bool = False):
"""Fetches the latest defense finder models.
The models will be downloaded from mdmparis repositories and installed on macsydata.
Expand All @@ -44,7 +46,7 @@ def update(models_dir=None):
Models repository: https://github.com/mdmparis/defense-finder-models.
"""
defense_finder_updater.update_models(models_dir)
defense_finder_updater.update_models(models_dir, force_reinstall)


@cli.command()
Expand Down
8 changes: 5 additions & 3 deletions defense_finder_updater/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import shlex
from macsypy.scripts import macsydata

def update_models(models_dir):

def update_models(models_dir, force_reinstall: bool):
# Updating DefenseFinder models
args_models_dir = f"-t {models_dir}" if models_dir is not None else "-u"
cmd_args = f"install -U {args_models_dir} --org mdmparis defense-finder-models"
args_force = "-f" if force_reinstall else ""
cmd_args = f"install -U {args_models_dir} {args_force} --org mdmparis defense-finder-models"
macsydata.main(shlex.split(cmd_args))

# Updating CASFinder models
args_models_dir = f"-t {models_dir}" if models_dir is not None else "-u"
cmd_args = f"install -U {args_models_dir} CasFinder"
cmd_args = f"install -U {args_models_dir} {args_force} CasFinder"
macsydata.main(shlex.split(cmd_args))

0 comments on commit 39dc849

Please sign in to comment.