recommendation endpoint - extract parameters from call - extract items to score from any data keys provided - get recommender from Flask app config - call recommender - construct JSON response
()
| 59 | |
| 60 | @recommend_blueprint.route('/recommend',methods=['GET','POST']) |
| 61 | def do_recommend(): |
| 62 | """ |
| 63 | recommendation endpoint |
| 64 | |
| 65 | - extract parameters from call |
| 66 | - extract items to score from any data keys provided |
| 67 | - get recommender from Flask app config |
| 68 | - call recommender |
| 69 | - construct JSON response |
| 70 | """ |
| 71 | input = extract_input() |
| 72 | |
| 73 | data_set = set() |
| 74 | for data_key in input['data_keys_list']: |
| 75 | raw_data = memcache_get(data_key) |
| 76 | raw_data = raw_data if raw_data != None else '[]' |
| 77 | data_set |= get_data_set(raw_data) |
| 78 | |
| 79 | data_set -= set(input['exclusion_items_list']) |
| 80 | |
| 81 | recommender = current_app.config["seldon_recommender"] |
| 82 | recs = recommender.recommend(input['user_id'],ids=data_set,recent_interactions=input['recent_interactions_list'],limit=input['limit'],client=input['client']) |
| 83 | |
| 84 | f=format_recs(recs) |
| 85 | json = jsonify(f) |
| 86 | return json |
| 87 | |
| 88 |
nothing calls this directly
no test coverage detected