diff --git a/web/serve.py b/web/serve.py index d6cd2e7..293a38a 100644 --- a/web/serve.py +++ b/web/serve.py @@ -210,18 +210,6 @@ def model_thumb(name): cache_timeout=60*60) -@app.route('/eval//') -def eval_image(bucket, filename): - filepath = os.path.join(LOCAL_EVAL_DIR, bucket, filename) - if is_naughty(filepath, LOCAL_EVAL_DIR, '.png'): - return '' - - return send_from_directory( - LOCAL_EVAL_DIR, - os.path.join(bucket, filename), - cache_timeout=30*60) - - def _fstat_dir(directory, top_dir): if not os.path.isdir(directory): return [] @@ -454,44 +442,50 @@ def pro_game_view(filename): ) -@app.route('//figure-three') -def figure_three(bucket): - eval_path = os.path.join(LOCAL_EVAL_DIR, bucket) - exists = os.path.exists(os.path.join(eval_path, 'move_acc.png')) +def parse_fig3_data(bucket): + fig3_json = '{"acc":{}, "mse":{}, "num":{}}' + + json_file = os.path.join(LOCAL_EVAL_DIR, bucket, "fig3.json") + if os.path.exists(json_file): + with open(json_file, "r") as f: + fig3_json = f.read() - # This is a longtime request from andrew. - key = '{}/fig3-json'.format(bucket) - fig3_data = cache.get(key) - if fig3_data is None: - fig3_json = '{"acc":{"0":0.01}, "mse":{"0":0.25}, "num":{"0":1}}' + fig3_data = [] + try: + fig3_json = json.loads(fig3_json) + for k, v in fig3_json["num"].items(): + acc = fig3_json["acc"][k] + mse = fig3_json["mse"][k] + fig3_data.append((v, acc, mse)) + except Exception as e: + print("Error parsing fig3 json:", e) - json_file = os.path.join(eval_path, "fig3.json") - if os.path.exists(json_file): - with open(json_file, "r") as f: - fig3_json = f.read() + return sorted(fig3_data) - fig3_data = [] - try: - fig3_json = json.loads(fig3_json) - for k, v in fig3_json["num"].items(): - acc = fig3_json["acc"][k] - mse = fig3_json["mse"][k] - fig3_data.append((v, acc, mse)) - except Exception as e: - print("Error parsing fig3 json:", e) - fig3_data.sort() +@app.route('//figure-three') +def figure_three(bucket): + figure_data = None + figure_three_data = [] + + # This list is a reasonable proxy for 'all' minigo runs. + for other_bucket in CloudyGo.MINIGO_TS: + key = '{}/fig3-json'.format(other_bucket) + fig3_data = cache.get(key) + if fig3_data is None: + fig3_data = parse_fig3_data(other_bucket) + cache.set(key, fig3_data, timeout=5 * 60) + + if other_bucket == bucket: + figure_data = fig3_data - cache.set(key, fig3_data, timeout=5 * 60) + for values in fig3_data: + figure_three_data.append((other_bucket,) + values) return render_template('figure-three.html', bucket=bucket, - exists=exists, - fig3_data=fig3_data, - eval_files=[ - 'move_acc.png', 'value_mse.png', - 'move_acc2.png', 'value_mse2.png', - ], + fig3_data=figure_data, + figure_three_data=figure_three_data, ) diff --git a/web/templates/figure-three.html b/web/templates/figure-three.html index 687120f..c8fd53c 100644 --- a/web/templates/figure-three.html +++ b/web/templates/figure-three.html @@ -16,7 +16,7 @@ {% from "macros.html" import models_link, bucket_name, - bootstrap_links, favicon_links, navbar with context %} + bootstrap_links, favicon_links, navbar, tip with context %} @@ -28,6 +28,7 @@ +