Skip to content

Commit

Permalink
docker prod volume paths, log verbosity
Browse files Browse the repository at this point in the history
mount /data/recommenders volume to production builds
adjust recommender log verbosity


Former-commit-id: fc800d7
  • Loading branch information
hjwilli committed Dec 2, 2020
1 parent 9445d5a commit 1721fb3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
7 changes: 4 additions & 3 deletions ai/recommender/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,22 +179,23 @@ def _train_empty_rec(self,
# load serialized rec, or initialize from the given
# knowledgebase
logger.info(f"load_serialized_rec='{load_serialized_rec}'")
logger.info(f"self.serialized_rec_path='{self.serialized_rec_path}'")

if load_serialized_rec == "always":
if not os.path.exists(self.serialized_rec_path):
raise ValueError(f"load_serialized_rec='{load_serialized_rec}'"
" but cannot load serialized recommender:"
" '{self.serialized_rec_path}'")
f" '{self.serialized_rec_path}'")
self.load(self.serialized_rec_path, knowledgebase_results)

elif load_serialized_rec == "if_exists":
if os.path.exists(self.serialized_rec_path):
logger.info(f"Loading serialized recommender:"
" {self.serialized_rec_path}")
f" '{self.serialized_rec_path}'")
self.load(self.serialized_rec_path, knowledgebase_results)
else:
logger.warn(f"Not loading serialized recommender, file does "
"not exist: {self.serialized_rec_path}")
f"not exist: '{self.serialized_rec_path}'")
if knowledgebase_results is not None:
logger.info(f"Initializing new recommender from provided "
"knowledgebase")
Expand Down
17 changes: 9 additions & 8 deletions ai/recommender/surprise_recommenders.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)
ch = logging.StreamHandler()
formatter = logging.Formatter('%(module)s: %(levelname)s: %(message)s')
ch.setFormatter(formatter)
Expand Down Expand Up @@ -100,15 +100,16 @@ def __init__(self,
self.ml_type = ml_type

if metric is None:
logger.debug('metric is None, setting...')
logger.warning('metric is None, setting...')
self.metric='bal_accuracy' if self.ml_type=='classifier' else 'mse'
else:
self.metric = metric
assert(self.metric is not None)

logger.debug('self.algo_name: '+self.algo_name)
logger.debug('ml_type: '+self.ml_type)
logger.debug('metric: '+self.metric)
logger.info('initlizing SurpriseRecommender')
logger.info('self.algo_name: '+self.algo_name)
logger.info('ml_type: '+self.ml_type)
logger.info('metric: '+self.metric)

self.min_epochs = 10
self.max_epochs = 100
Expand Down Expand Up @@ -439,7 +440,7 @@ def _update_model(self,results_data):
self.algo.n_epochs = min(len(results_data),self.max_epochs)
self.algo.n_epochs = max(self.algo.n_epochs,self.min_epochs)

logger.debug('fitting self.algo...')
logger.info('fitting self.algo...')
self.algo.partial_fit(self.trainset)
logger.debug('done.')
logger.debug('model SVD updated')
logger.info('done.')
logger.info('model SVD updated')
1 change: 1 addition & 0 deletions docker-compose-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
volumes:
- "/appsrc"
- "./data/datasets/user:/appsrc/data/datasets/user"
- "./data/recommenders/pennaiweb:/appsrc/data/recommenders/pennaiweb"
- "./target:/appsrc/target"
ports:
- "5080:5080"
Expand Down

0 comments on commit 1721fb3

Please sign in to comment.