def upload_to_gae(filename, options): with open(filename) as f: model_json = f.read() model = json.loads(model_json) require_property("slug", model) require_property("engine_class", model) if options.create: require_property("title", model) require_property("description", model) print json.dumps(model, indent=4) # a bit redundant, but re-print the key properties so they are # very visible when the user is prompted to confirm upload print "=====" print "slug = '%s'" % model.get("slug") print "engine_class = '%s'" % model.get("engine_class") print "title = '%s'" % model.get("title") print "decription = '%s'" % model.get("description") print "=====" ans = raw_input("Are you sure you want to upload to GAE? [y/N] ") if ans in ['Y', 'y']: oauth_fetcher.fetch_url( '/api/internal/dev/assessment/params', {'data': model_json}) else: print "Canceling upload."
def upload_to_gae(filename, options): with open(filename) as f: model_json = f.read() model = json.loads(model_json) require_property("slug", model) require_property("engine_class", model) if options.create: require_property("title", model) require_property("description", model) print json.dumps(model, indent=4) # a bit redundant, but re-print the key properties so they are # very visible when the user is prompted to confirm upload print "=====" print "slug = '%s'" % model.get("slug") print "engine_class = '%s'" % model.get("engine_class") print "title = '%s'" % model.get("title") print "decription = '%s'" % model.get("description") print "=====" ans = raw_input("Are you sure you want to upload to GAE? [y/N] ") if ans in ['Y', 'y']: oauth_fetcher.fetch_url('/api/internal/dev/assessment/params', {'data': model_json}) else: print "Canceling upload."
def upload_to_gae(score_type, video_infos): try: video_keys = video_infos.keys() video_keys.sort(key=lambda video_key: video_infos[video_key].index) row_dicts = [None] * len(video_keys) for info in video_infos.values(): row_dicts[info.index] = info.best_matches oauth_fetcher.fetch_url( '/api/v1/dev/videorec_matrix', { 'score_type': score_type, 'data': json.dumps({ 'video_keys': video_keys, 'matrix_rows': row_dicts, }), }) except urllib2.URLError as e: print >> sys.stderr, "Unable to access GAE:" print >> sys.stderr, e
def upload_to_gae(score_type, version, video_infos): try: video_keys = video_infos.keys() video_keys.sort(key=lambda video_key: video_infos[video_key].index) row_dicts = [None] * len(video_keys) for info in video_infos.values(): row_dicts[info.index] = info.best_matches oauth_fetcher.fetch_url( "/api/v1/dev/videorec_matrix", { "score_type": score_type, "version": version, "data": json.dumps({"video_keys": video_keys, "matrix_rows": row_dicts}), }, ) except urllib2.URLError as e: print >> sys.stderr, "Unable to access GAE:" print >> sys.stderr, e
def upload_to_gae(score_type, version, video_infos): try: video_keys = video_infos.keys() video_keys.sort(key=lambda video_key: video_infos[video_key].index) row_dicts = [None] * len(video_keys) for info in video_infos.values(): row_dicts[info.index] = info.best_matches oauth_fetcher.fetch_url( '/api/internal/dev/videorec_matrix', { 'score_type': score_type, 'version': version, 'data': json.dumps({ 'video_keys': video_keys, 'matrix_rows': row_dicts, }), }) except urllib2.URLError as e: print >> sys.stderr, "Unable to access GAE:" print >> sys.stderr, e
def main(score_type, version): print "About to modify video recommendations data:" print " target: ", oauth_util.consts.SERVER_URL print " score_type: ", score_type print " version: ", version confirm = raw_input("Proceed? (y/[n]): ") if confirm.lower() in ['y', 'yes']: # This will throw on 4xx, 5xx resp = oauth_fetcher.fetch_url('/api/internal/dev/videorec_version', { 'score_type': score_type, 'version': version, }) resp = json.loads(resp) print "Success!" print "To revert back, run:" print "set_video_matrix_version.py '%s' '%s'" % (score_type, resp['previous'])
def main(score_type, version): print "About to modify video recommendations data:" print " target: ", oauth_util.consts.SERVER_URL print " score_type: ", score_type print " version: ", version confirm = raw_input("Proceed? (y/[n]): ") if confirm.lower() in ['y', 'yes']: # This will throw on 4xx, 5xx resp = oauth_fetcher.fetch_url( '/api/internal/dev/videorec_version', { 'score_type': score_type, 'version': version, }) resp = json.loads(resp) print "Success!" print "To revert back, run:" print "set_video_matrix_version.py '%s' '%s'" % ( score_type, resp['previous'])