Spaces:
Runtime error
Runtime error
Commit ·
1b0277d
1
Parent(s): 0233854
fix model count
Browse files- app.py +5 -4
- src/backend.py +5 -3
- src/evaluation.py +1 -0
app.py
CHANGED
|
@@ -136,19 +136,21 @@ def get_leaderboard_df():
|
|
| 136 |
try:
|
| 137 |
with open(filename) as fp:
|
| 138 |
report = json.load(fp)
|
| 139 |
-
user_id, model_id = report["config"]["model_id"].split("/")
|
| 140 |
-
row = {"user_id": user_id, "model_id": model_id, "model_sha": report["config"]["model_sha"]}
|
| 141 |
if report["status"] == "DONE" and len(report["results"]) > 0:
|
|
|
|
|
|
|
| 142 |
env_ids = list(report["results"].keys())
|
| 143 |
assert len(env_ids) == 1, "Only one environment supported for the moment"
|
| 144 |
row["env_id"] = env_ids[0]
|
| 145 |
row["iqm_episodic_return"] = iqm(report["results"][env_ids[0]]["episodic_returns"])
|
| 146 |
-
|
| 147 |
except Exception as e:
|
| 148 |
logger.error(f"Error while processing {filename}: {e}")
|
| 149 |
|
| 150 |
df = pd.DataFrame(data) # create DataFrame
|
| 151 |
df = df.fillna("") # replace NaN values with empty strings
|
|
|
|
|
|
|
| 152 |
return df
|
| 153 |
|
| 154 |
|
|
@@ -295,7 +297,6 @@ with gr.Blocks(css=css) as demo:
|
|
| 295 |
# Load the first video of the first environment
|
| 296 |
demo.load(refresh_one_video(df, env_ids[0]), outputs=[all_gr_videos[env_ids[0]]])
|
| 297 |
|
| 298 |
-
|
| 299 |
with gr.TabItem("🚀 Getting my agent evaluated"):
|
| 300 |
with open("texts/getting_my_agent_evaluated.md") as fp:
|
| 301 |
gr.Markdown(fp.read())
|
|
|
|
| 136 |
try:
|
| 137 |
with open(filename) as fp:
|
| 138 |
report = json.load(fp)
|
|
|
|
|
|
|
| 139 |
if report["status"] == "DONE" and len(report["results"]) > 0:
|
| 140 |
+
user_id, model_id = report["config"]["model_id"].split("/")
|
| 141 |
+
row = {"user_id": user_id, "model_id": model_id, "model_sha": report["config"]["model_sha"]}
|
| 142 |
env_ids = list(report["results"].keys())
|
| 143 |
assert len(env_ids) == 1, "Only one environment supported for the moment"
|
| 144 |
row["env_id"] = env_ids[0]
|
| 145 |
row["iqm_episodic_return"] = iqm(report["results"][env_ids[0]]["episodic_returns"])
|
| 146 |
+
data.append(row)
|
| 147 |
except Exception as e:
|
| 148 |
logger.error(f"Error while processing {filename}: {e}")
|
| 149 |
|
| 150 |
df = pd.DataFrame(data) # create DataFrame
|
| 151 |
df = df.fillna("") # replace NaN values with empty strings
|
| 152 |
+
# Save to csv
|
| 153 |
+
df.to_csv("leaderboard.csv", index=False)
|
| 154 |
return df
|
| 155 |
|
| 156 |
|
|
|
|
| 297 |
# Load the first video of the first environment
|
| 298 |
demo.load(refresh_one_video(df, env_ids[0]), outputs=[all_gr_videos[env_ids[0]]])
|
| 299 |
|
|
|
|
| 300 |
with gr.TabItem("🚀 Getting my agent evaluated"):
|
| 301 |
with open("texts/getting_my_agent_evaluated.md") as fp:
|
| 302 |
gr.Markdown(fp.read())
|
src/backend.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import json
|
| 2 |
import os
|
|
|
|
| 3 |
import re
|
| 4 |
import tempfile
|
| 5 |
|
|
@@ -48,7 +49,7 @@ def _backend_routine():
|
|
| 48 |
# Run an evaluation on the models
|
| 49 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 50 |
commits = []
|
| 51 |
-
model_id, sha = pending_models
|
| 52 |
logger.info(f"Running evaluation on {model_id}")
|
| 53 |
report = {"config": {"model_id": model_id, "model_sha": sha}}
|
| 54 |
try:
|
|
@@ -84,5 +85,6 @@ def backend_routine():
|
|
| 84 |
except Exception as e:
|
| 85 |
logger.error(f"{e.__class__.__name__}: {str(e)}")
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
+
import random
|
| 4 |
import re
|
| 5 |
import tempfile
|
| 6 |
|
|
|
|
| 49 |
# Run an evaluation on the models
|
| 50 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
| 51 |
commits = []
|
| 52 |
+
model_id, sha = random.choice(pending_models)
|
| 53 |
logger.info(f"Running evaluation on {model_id}")
|
| 54 |
report = {"config": {"model_id": model_id, "model_sha": sha}}
|
| 55 |
try:
|
|
|
|
| 85 |
except Exception as e:
|
| 86 |
logger.error(f"{e.__class__.__name__}: {str(e)}")
|
| 87 |
|
| 88 |
+
|
| 89 |
+
if __name__ == "__main__":
|
| 90 |
+
backend_routine()
|
src/evaluation.py
CHANGED
|
@@ -112,6 +112,7 @@ ALL_ENV_IDS = [
|
|
| 112 |
|
| 113 |
NUM_EPISODES = 50
|
| 114 |
|
|
|
|
| 115 |
class NoopResetEnv(gym.Wrapper[np.ndarray, int, np.ndarray, int]):
|
| 116 |
"""
|
| 117 |
Sample initial states by taking random number of no-ops on reset.
|
|
|
|
| 112 |
|
| 113 |
NUM_EPISODES = 50
|
| 114 |
|
| 115 |
+
|
| 116 |
class NoopResetEnv(gym.Wrapper[np.ndarray, int, np.ndarray, int]):
|
| 117 |
"""
|
| 118 |
Sample initial states by taking random number of no-ops on reset.
|