Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (55 loc) · 2.46 KB
/
Copy pathMakefile
File metadata and controls
66 lines (55 loc) · 2.46 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
.PHONY: help env weights train-safety train-task cpo collect figures reproduce clean
.DEFAULT_GOAL := help
# ------------------------------------------------------------------ knobs ----
ENV ?= SafetyCarCircle2-v0 # SafetyCarCircle2-v0 | SafetyCarGoal1-v0
CFG ?= configs/task/circle_rollout.yaml
SEED ?= 0
DATA ?= data/results
FIGDIR ?= figures
help:
@echo "PORL reproduction targets:"
@echo " make env - print the one-time install steps"
@echo " make weights - download published safety-policy weights"
@echo " make train-safety CFG=configs/safety_policy/circle.yaml"
@echo " make train-task CFG=configs/task/circle_rollout.yaml SEED=0"
@echo " make cpo ENV=SafetyCarCircle2-v0 SEED=0"
@echo " make collect - rebuild data/results/*.csv from local runs (retrain path)"
@echo " make figures - regenerate figures/ from committed data/results/ (no GPU)"
@echo " make reproduce - full retrain -> collect -> figures (slow, needs GPU)"
env:
@echo "conda create -n porl python=3.10 -y && conda activate porl"
@echo "pip install -e external/safety-stable-baselines"
@echo "pip install -e external/safety-stable-baselines/integrations/safety-gymnasium"
@echo "pip install -e external/Safe-Policy-Optimization"
@echo "pip install -e ."
weights:
bash scripts/fetch_weights.sh
train-safety:
python -m porl.train_safety_policy --config $(CFG) --seed $(SEED)
train-task:
python -m porl.train --config $(CFG) --seed $(SEED)
cpo:
python -m porl.run_cpo --env $(ENV) --seed $(SEED)
collect:
python -m analysis.collect_results --out-dir $(DATA)
figures:
python -m analysis.plot_figures --data-dir $(DATA) --out-dir $(FIGDIR)
# Full end-to-end reproduction. Trains the 2 safety policies, then 5 seeds x 2 envs x
# {naive, value, rollout} task policies + CPO, collects, and plots. Expect many GPU-hours.
reproduce:
python -m porl.train_safety_policy --config configs/safety_policy/circle.yaml
python -m porl.train_safety_policy --config configs/safety_policy/goal.yaml
@for env in circle goal; do \
for method in naive value rollout; do \
for s in 0 1 2 3 4; do \
python -m porl.train --config configs/task/$$env\_$$method.yaml --seed $$s ; \
done ; \
done ; \
done
@for envid in SafetyCarCircle2-v0 SafetyCarGoal1-v0; do \
for s in 0 1 2 3 4; do python -m porl.run_cpo --env $$envid --seed $$s ; done ; \
done
$(MAKE) collect
$(MAKE) figures
clean:
rm -rf $(FIGDIR)/*.pdf $(FIGDIR)/*.svg $(FIGDIR)/*.png