From 5499f9413c182dad8a79bcf14902b0e96f6eeba2 Mon Sep 17 00:00:00 2001 From: Sadanand Modak Date: Thu, 30 Nov 2023 18:25:16 -0600 Subject: [PATCH] Move over changes from fork copy to branch --- ...-amrl-user-ut-amrl-project-SocialGym2-.txt | 1 + .../configs/1_31_23/door/sacadrl.json | 2 +- log/leaderboard.py | 68 +++- log/template.json | 1 + log/templates/form.html | 303 ++++++++++++++++++ log/templates/leaderboard.html | 1 + log/templates/page.html | 173 ++++++++++ log/templates/popup.html | 31 ++ 8 files changed, 576 insertions(+), 4 deletions(-) create mode 100644 -home-amrl-user-ut-amrl-project-SocialGym2-.txt create mode 100644 log/template.json create mode 100644 log/templates/form.html create mode 100644 log/templates/page.html create mode 100644 log/templates/popup.html diff --git a/-home-amrl-user-ut-amrl-project-SocialGym2-.txt b/-home-amrl-user-ut-amrl-project-SocialGym2-.txt new file mode 100644 index 0000000..5e643bc --- /dev/null +++ b/-home-amrl-user-ut-amrl-project-SocialGym2-.txt @@ -0,0 +1 @@ +/home/amrl-user/ut-amrl/project/SocialGym2/log \ No newline at end of file diff --git a/config_runner/configs/1_31_23/door/sacadrl.json b/config_runner/configs/1_31_23/door/sacadrl.json index d09fd05..c252f9e 100644 --- a/config_runner/configs/1_31_23/door/sacadrl.json +++ b/config_runner/configs/1_31_23/door/sacadrl.json @@ -1,6 +1,6 @@ { "num_agents": [[0,2]], - "eval_num_agents": [3, 4, 5, 7, 10, 20], + "eval_num_agents": [3], "train_length": 250000, "ending_eval_trials": 25, "eval_frequency": 0, diff --git a/log/leaderboard.py b/log/leaderboard.py index 6ac90da..30058b7 100644 --- a/log/leaderboard.py +++ b/log/leaderboard.py @@ -1,9 +1,60 @@ -from flask import Flask, render_template +from flask import Flask, render_template, request import json import os +import threading +from queue import Queue +from pathlib import Path +import sys +parent_dir = Path(__file__).resolve().parent.parent +sys.path.insert(1, str(parent_dir)) +from config_runner.run import run + app = Flask(__name__) +configs = Queue() + +@app.route('/form') +def form(): + reports = get_eval_reports() + return render_template("form.html", reports=reports) + +@app.route('/upload', methods=['POST']) +def upload(): + # Access the uploaded file, and form fields + checkpoint_file = request.files['checkpoint'] + policy_algo_sb3_contrib = request.form['policy_algo_sb3_contrib'] + policy_algo_name = request.form['policy_algo_name'] + policy_name = request.form['policy_name'] + n_steps = request.form['n_steps'] + + # You can now save the file and use the form data to process further. + # This example only returns a confirmation message. + + # Process and save the file, etc... + # with open("log/template.json", 'r') as json_file: + # json_data = json.load(json_file) + + # os.makedirs(f"data", exist_ok=True) + # checkpoint_file.save(f"data/{policy_name}.zip") + + # json_data['policy_algo_name'] = policy_algo_name + # json_data['policy_name'] = policy_name + # json_data['continue_from'] = f"data/{policy_name}.zip" + # json_data['policy_algo_sb3_contrib'] = policy_algo_sb3_contrib + # json_data['policy_algo_kwargs'] = {"n_steps": n_steps} + + # os.makedirs("config_runner/configs/log", exist_ok=True) + # with open(f"config_runner/configs/log/{policy_name}.json", 'w') as updated_json_file: + # json.dump(json_data, updated_json_file, indent=2) + # configs.put(f"log/{policy_name}.json") + + return render_template('popup.html', + policy_algo_sb3_contrib=policy_algo_sb3_contrib, + policy_algo_name=policy_algo_name, + policy_name=policy_name, + n_steps=n_steps) + def get_eval_reports(): log_directory = os.path.join('..', 'log') reports = [] @@ -22,10 +73,21 @@ def get_eval_reports(): reports.append(report_data['3']) return reports -@app.route('/') +@app.route('/leaderboard') def leaderboard(): reports = get_eval_reports() return render_template('leaderboard.html', reports=reports) +def runner(): + print("Started Thread") + while True: + print("Waiting") + config = configs.get(block=True) + print("Got config: ", config) + run([config]) + if __name__ == "__main__": - app.run(debug=True, port=8000) \ No newline at end of file + runner = threading.Thread(target=runner) + runner.start() + app.run(debug=True, port=8080) + runner.join() \ No newline at end of file diff --git a/log/template.json b/log/template.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/log/template.json @@ -0,0 +1 @@ +{} diff --git a/log/templates/form.html b/log/templates/form.html new file mode 100644 index 0000000..5bd296d --- /dev/null +++ b/log/templates/form.html @@ -0,0 +1,303 @@ + + + + + + Model Checkpoint Upload and Leaderboard + + + + +
+
+

Upload Model Checkpoint

+
+ + + + +
+ + + + +
+ + + + + + + + + + + +
+
+ +
+

SocialGym2 Benchmarking Leaderboard

+ + + + + + + + + + + + + + + + {% for report in reports %} + + + + + + + + + + + + {% endfor %} + +
TimestampSuccess RateCollisionsAvg. LengthAvg. Velocity DeltaTime StillIncorrect Enter RateIncorrect Exit Rate
{{ report.timestamp }}{{ report.success_rate }}{{ report.collisions }}{{ report.avg_length }}{{ report.avg_velocity_delta }}{{ report.time_still }}{{ report.incorrect_enter_rate }}{{ report.incorrect_exit_rate }}
+
+
+ + + + + + + + + + diff --git a/log/templates/leaderboard.html b/log/templates/leaderboard.html index b836290..dfb98c3 100644 --- a/log/templates/leaderboard.html +++ b/log/templates/leaderboard.html @@ -15,6 +15,7 @@ .container { width: 80%; margin: auto; + display: inline-block; overflow: hidden; } diff --git a/log/templates/page.html b/log/templates/page.html new file mode 100644 index 0000000..a18a0dd --- /dev/null +++ b/log/templates/page.html @@ -0,0 +1,173 @@ + + + + + +Main Page + + + + + + + +
+
+

Upload Model Checkpoint

+
+ + + + +
+ + + + +
+ + + + + + + + + + + +
+
+
+

SocialGym2 Multi-Agent Simulator Leaderboard

+ + + + + + + + + + + + + + + + {% for report in reports %} + + + + + + + + + + + {% endfor %} + +
TimestampSuccess RateCollisionsAvg. LengthAvg. Velocity DeltaTime StillIncorrect Enter RateIncorrect Exit Rate
{{ report.timestamp }}{{ report.success_rate }}{{ report.collisions }}{{ report.avg_length }}{{ report.avg_velocity_delta }}{{ report.time_still }}{{ report.incorrect_enter_rate }}{{ report.incorrect_exit_rate }}
+
+
+ + + \ No newline at end of file diff --git a/log/templates/popup.html b/log/templates/popup.html new file mode 100644 index 0000000..84341ca --- /dev/null +++ b/log/templates/popup.html @@ -0,0 +1,31 @@ + + + + + Popup + + + + + + + +