-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
211 lines (192 loc) · 6.85 KB
/
Copy pathaction.yml
File metadata and controls
211 lines (192 loc) · 6.85 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: "deltatau-audit"
description: "Time robustness audit for RL agents — find timing failures before deployment"
branding:
icon: "shield"
color: "blue"
inputs:
command:
description: "Command to run: demo, audit-sb3, audit-cleanrl, audit-hf, fix-sb3"
required: false
default: "demo"
model:
description: "Path to SB3 model (.zip) — for audit-sb3, audit-hf, fix-sb3"
required: false
algo:
description: "SB3 algorithm (ppo, sac, td3, a2c)"
required: false
default: "ppo"
checkpoint:
description: "Path to agent checkpoint (.pt file) — for audit-cleanrl, fix-cleanrl"
required: false
agent-module:
description: "Python module path for CleanRL agent class (e.g. 'my_pkg.agent:Agent') — for audit-cleanrl"
required: false
env:
description: "Gymnasium environment ID (e.g. CartPole-v1, HalfCheetah-v5)"
required: false
episodes:
description: "Episodes per condition"
required: false
default: "20"
output:
description: "Output directory"
required: false
default: "audit_report"
extras:
description: "pip extras to install (e.g. 'sb3,mujoco')"
required: false
default: "demo"
deploy-threshold:
description: "Deployment score threshold for pass (0-1)"
required: false
default: "0.80"
stress-threshold:
description: "Stress score threshold for warn (0-1)"
required: false
default: "0.50"
workers:
description: "Parallel workers for episode collection (integer or 'auto')"
required: false
default: "auto"
seed:
description: "Random seed for reproducible results"
required: false
seeds:
description: "Multi-seed sweep list (space/comma separated, e.g. '0 1 2 3 4')"
required: false
default: ""
ci-min-deployment-pass-rate:
description: "Multi-seed gate: minimum deployment pass rate (0-1)"
required: false
default: "0.80"
ci-min-stress-pass-rate:
description: "Multi-seed gate: minimum stress pass rate (0-1)"
required: false
default: "0.50"
extra-args:
description: "Additional CLI arguments (e.g. '--adaptive --target-ci-width 0.05')"
required: false
default: ""
python-version:
description: "Python version"
required: false
default: "3.11"
outputs:
status:
description: "Audit status: pass, warn, or fail"
value: ${{ steps.audit.outputs.status }}
deployment-score:
description: "Deployment robustness score (0-1)"
value: ${{ steps.audit.outputs.deployment_score }}
stress-score:
description: "Stress robustness score (0-1)"
value: ${{ steps.audit.outputs.stress_score }}
report-dir:
description: "Path to the generated report directory"
value: ${{ inputs.output }}
runs:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-deltatau-${{ inputs.extras }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-deltatau-${{ inputs.extras }}-
${{ runner.os }}-pip-deltatau-
- name: Install deltatau-audit
shell: bash
run: pip install "deltatau-audit[${{ inputs.extras }}]"
- name: Run audit
id: audit
shell: bash
run: |
set +e
SINGLE_SEED_FLAG=""
if [ -n "${{ inputs.seed }}" ]; then
SINGLE_SEED_FLAG="--seed ${{ inputs.seed }}"
fi
SWEEP_SEEDS_FLAG=""
if [ -n "${{ inputs.seeds }}" ]; then
CLEAN_SEEDS=$(echo "${{ inputs.seeds }}" | tr ',' ' ')
SWEEP_SEEDS_FLAG="--seeds $CLEAN_SEEDS"
fi
AUDIT_SEED_FLAGS="$SINGLE_SEED_FLAG"
if [ -n "$SWEEP_SEEDS_FLAG" ]; then
AUDIT_SEED_FLAGS="$SWEEP_SEEDS_FLAG"
fi
COMMON_FLAGS="--ci \
--episodes ${{ inputs.episodes }} \
--workers ${{ inputs.workers }} \
--ci-deploy-threshold ${{ inputs.deploy-threshold }} \
--ci-stress-threshold ${{ inputs.stress-threshold }} \
--ci-min-deployment-pass-rate ${{ inputs.ci-min-deployment-pass-rate }} \
--ci-min-stress-pass-rate ${{ inputs.ci-min-stress-pass-rate }} \
--format markdown \
--out ${{ inputs.output }} \
${{ inputs.extra-args }}"
if [ "${{ inputs.command }}" = "demo" ]; then
python -m deltatau_audit demo cartpole $COMMON_FLAGS $SINGLE_SEED_FLAG
EXIT_CODE=$?
elif [ "${{ inputs.command }}" = "audit-sb3" ]; then
python -m deltatau_audit audit-sb3 \
--algo ${{ inputs.algo }} \
--model "${{ inputs.model }}" \
--env "${{ inputs.env }}" \
$COMMON_FLAGS $AUDIT_SEED_FLAGS
EXIT_CODE=$?
elif [ "${{ inputs.command }}" = "audit-cleanrl" ]; then
CHECKPOINT_FLAG=""
if [ -n "${{ inputs.checkpoint }}" ]; then
CHECKPOINT_FLAG="--checkpoint ${{ inputs.checkpoint }}"
fi
AGENT_MODULE_FLAG=""
if [ -n "${{ inputs.agent-module }}" ]; then
AGENT_MODULE_FLAG="--agent-module ${{ inputs.agent-module }}"
fi
python -m deltatau_audit audit-cleanrl \
--env "${{ inputs.env }}" \
$CHECKPOINT_FLAG \
$AGENT_MODULE_FLAG \
$COMMON_FLAGS $AUDIT_SEED_FLAGS
EXIT_CODE=$?
elif [ "${{ inputs.command }}" = "audit-hf" ]; then
python -m deltatau_audit audit-hf \
--algo ${{ inputs.algo }} \
--repo "${{ inputs.model }}" \
--env "${{ inputs.env }}" \
$COMMON_FLAGS $AUDIT_SEED_FLAGS
EXIT_CODE=$?
elif [ "${{ inputs.command }}" = "fix-sb3" ]; then
python -m deltatau_audit fix-sb3 \
--algo ${{ inputs.algo }} \
--model "${{ inputs.model }}" \
--env "${{ inputs.env }}" \
$COMMON_FLAGS $SINGLE_SEED_FLAG
EXIT_CODE=$?
else
echo "Unknown command: ${{ inputs.command }}"
exit 1
fi
# Parse CI summary for outputs
if [ "${{ inputs.command }}" = "demo" ]; then
CI_JSON="${{ inputs.output }}/robust_wide/ci_summary.json"
else
CI_JSON="${{ inputs.output }}/ci_summary.json"
fi
if [ -f "$CI_JSON" ]; then
read -r STATUS DEP STR <<< $(python -c "import json; d=json.load(open('$CI_JSON')); print(d['status'], d.get('deployment_score', 0), d.get('stress_score', 0))")
echo "status=$STATUS" >> $GITHUB_OUTPUT
echo "deployment_score=$DEP" >> $GITHUB_OUTPUT
echo "stress_score=$STR" >> $GITHUB_OUTPUT
else
echo "status=unknown" >> $GITHUB_OUTPUT
echo "deployment_score=0" >> $GITHUB_OUTPUT
echo "stress_score=0" >> $GITHUB_OUTPUT
fi
exit $EXIT_CODE