def __init__(self, datastore=None, USE_FEEDBACK=USE_FEEDBACK): """Set the variables and load model data.""" self.datastore = datastore self.USE_FEEDBACK = convert_string2bool_env(USE_FEEDBACK) self.package_id_dict = OrderedDict() self.id_package_dict = OrderedDict() self.beta = None self.theta = None self.alpha = None self.manifest_id_dict = OrderedDict() self.feedback_id_dict = OrderedDict() self.manifests = 0 self.packages = 0 self.epsilon = Gamma(tf.constant( a_c), tf.constant(a_c) / tf.constant(b_c)).\ prob(tf.constant(K, dtype=tf.float32)).eval(session=tf.Session()) self.theta_dummy = Poisson( np.array([ self.epsilon * Gamma(tf.constant(a), self.epsilon).prob( tf.constant(K, dtype=tf.float32)).eval(session=tf.Session()) ] * K, dtype=float)) if isinstance(datastore, S3DataStore): # pragma: no-cover self.load_s3() else: self.load_local() self.manifests = self.theta.shape[0] self.packages = self.beta.shape[0] self.dummy_result = self.theta_dummy.prob( self.beta).eval(session=tf.Session())
def __init__(self, datastore=None, USE_FEEDBACK=USE_FEEDBACK): """Set the variables and load model data.""" self.datastore = datastore self.USE_FEEDBACK = convert_string2bool_env(USE_FEEDBACK) self.package_id_dict = OrderedDict() self.id_package_dict = OrderedDict() self.beta = None self.theta = None self.alpha = None self.manifest_id_dict = OrderedDict() self.feedback_id_dict = OrderedDict() self.manifests = 0 self.logger = logging.getLogger(__name__ + '.HPFScoring') self.packages = 0 self.loadObjects()
flask_app.logger.addHandler(handler) flask_app.config['LOGGER_HANDLER_POLICY'] = 'never' flask_app.logger.setLevel(logging.DEBUG) app = connexion.FlaskApp(__name__) setup_logging(app.app) CORS(app.app) global scoring_status global scoring_object global s3_object if HPF_SCORING_REGION != "": if convert_string2bool_env(USE_CLOUD_SERVICES): s3_object = AmazonS3(bucket_name=AWS_S3_BUCKET_NAME, aws_access_key_id=AWS_S3_ACCESS_KEY_ID, aws_secret_access_key=AWS_S3_SECRET_ACCESS_KEY) s3_object.connect() app.scoring_object = HPFScoring(datastore=s3_object) else: app.scoring_object = HPFScoring(LocalDataStore("tests/test_data")) app.scoring_status = True else: app.scoring_status = False current_app.logger.warning("Have not loaded a model for scoring!") def heart_beat(): """Handle the / REST API call."""