Skip to content

Commit

Permalink
Merge branch 'create_update_command' into 'master'
Browse files Browse the repository at this point in the history
Add update command that runs both init and train



See merge request !34
  • Loading branch information
lucasmoura committed Aug 13, 2016
2 parents c52cd97 + 72e9798 commit 2d2adfa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
54 changes: 37 additions & 17 deletions apprecommender/main/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,49 @@ def run_apprecommender(reference_pkgs):
return PERMISSION_DENIED


def run_initialize():
print "Initializing AppRecommender"
initialize = Initialize()

try:
initialize.prepare_data()
except OSError:
return PERMISSION_DENIED

return SUCCESS


def run_train():
print "Training machine learning"

try:
MachineLearning.train(MachineLearningBVA)
MachineLearning.train(MachineLearningBOW)
except IOError:
return PERMISSION_DENIED
except MachineLearningTrainError:
return ERROR_INIT_TRAIN

return SUCCESS


def run(args):
if args['init']:
print "Initializing AppRecommender"
initialize = Initialize()
if args['update']:
init_result = run_initialize()

try:
initialize.prepare_data()
except OSError:
return PERMISSION_DENIED
if init_result != SUCCESS:
return init_result

return SUCCESS
elif args['train']:
print "Training machine learning"
train_result = run_train()

try:
MachineLearning.train(MachineLearningBVA)
MachineLearning.train(MachineLearningBOW)
except IOError:
return PERMISSION_DENIED
except MachineLearningTrainError:
return ERROR_INIT_TRAIN
if train_result != SUCCESS:
return train_result

return SUCCESS
elif args['init']:
return run_initialize()
elif args['train']:
return run_train()
elif args['contribute']:
collect_user_data.main()
elif args['show_classifications']:
Expand Down
5 changes: 5 additions & 0 deletions apprecommender/main/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ def get_parser():
help='Disable recommendations when install a package with apt',
action='store_true')

parser.add_argument(
'--update',
help='Run both init and train commands',
action='store_true')

return parser

0 comments on commit 2d2adfa

Please sign in to comment.