forked from vwxyzjn/cleanrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreproduce.py
54 lines (48 loc) · 1.53 KB
/
reproduce.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import argparse
from distutils.util import strtobool
import requests
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="CleanRL Plots")
# Common arguments
parser.add_argument(
"--run",
type=str,
default="cleanrl/cleanrl.benchmark/runs/thq5rgnz",
help="the name of wandb project (e.g. cleanrl/cleanrl)",
)
parser.add_argument(
"--remove-entity",
type=lambda x: bool(strtobool(x)),
default=True,
nargs="?",
const=True,
help="if toggled, the wandb-entity will be removed",
)
args = parser.parse_args()
uri = args.run.replace("/runs", "")
requirements_txt_url = f"https://api.wandb.ai/files/{uri}/requirements.txt"
metadata_url = f"https://api.wandb.ai/files/{uri}/wandb-metadata.json"
metadata = requests.get(url=metadata_url).json()
if args.remove_entity:
a = []
wandb_entity_idx = None
for i in range(len(metadata["args"])):
if metadata["args"][i] == "--wandb-entity":
wandb_entity_idx = i
continue
if wandb_entity_idx and i == wandb_entity_idx + 1:
continue
a += [metadata["args"][i]]
else:
a = metadata["args"]
program = ["python"] + [metadata["program"]] + a
print(
f"""
# run the following
python3 -m venv venv
source venv/bin/activate
pip install -r {requirements_txt_url}
curl -OL https://api.wandb.ai/files/{uri}/code/{metadata["codePath"]}
{" ".join(program)}
"""
)