Skip to content

Commit 37e86df

Browse files
CI: comment reporter links on PRs (#35066)
* comment * Revert "Tomb Raider 4 (#35058)" This reverts commit 756aebd. * no dpeth * Reapply "Tomb Raider 4 (#35058)" This reverts commit 7143835. * no forks
1 parent 756aebd commit 37e86df

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.github/workflows/model_review.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "model review"
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
paths:
7+
- 'selfdrive/modeld/models/*.onnx'
8+
workflow_dispatch:
9+
10+
jobs:
11+
comment:
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
runs-on: ubuntu-latest
16+
if: github.repository == 'commaai/openpilot'
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- name: Checkout master
21+
uses: actions/checkout@v4
22+
with:
23+
ref: master
24+
path: base
25+
- run: git lfs pull
26+
- run: cd base && git lfs pull
27+
28+
- run: pip install onnx
29+
30+
- name: scripts/reporter.py
31+
id: report
32+
run: |
33+
echo "content<<EOF" >> $GITHUB_OUTPUT
34+
echo "## Model Review" >> $GITHUB_OUTPUT
35+
MASTER_PATH=${{ github.workspace }}/base python scripts/reporter.py >> $GITHUB_OUTPUT
36+
echo "EOF" >> $GITHUB_OUTPUT
37+
38+
- name: Post model report comment
39+
uses: marocchino/sticky-pull-request-comment@baa7203ed60924babbe5dcd0ac8eae3b66ec5e16
40+
with:
41+
header: model-review
42+
message: ${{ steps.report.outputs.content }}

scripts/reporter.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import glob
4+
import onnx
5+
6+
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))
7+
MASTER_PATH = os.getenv("MASTER_PATH", BASEDIR)
8+
MODEL_PATH = "/selfdrive/modeld/models/"
9+
10+
def get_checkpoint(f):
11+
model = onnx.load(f)
12+
metadata = {prop.key: prop.value for prop in model.metadata_props}
13+
return metadata['model_checkpoint'].split('/')[0]
14+
15+
if __name__ == "__main__":
16+
print("| | master | PR branch |")
17+
print("|-| ----- | --------- |")
18+
19+
for f in glob.glob(BASEDIR + MODEL_PATH + "/*.onnx"):
20+
# TODO: add checkpoint to DM
21+
if "dmonitoring" in f:
22+
continue
23+
24+
fn = os.path.basename(f)
25+
master = get_checkpoint(MASTER_PATH + MODEL_PATH + fn)
26+
pr = get_checkpoint(BASEDIR + MODEL_PATH + fn)
27+
print(
28+
"|", fn, "|",
29+
f"[{master}](https://reporter.comma.life/experiment/{master})", "|",
30+
f"[{pr}](https://reporter.comma.life/experiment/{pr})", "|"
31+
)

0 commit comments

Comments
 (0)