Skip to content

Commit c285d74

Browse files
authored
Merge pull request #212 from mlcommons/dev
Merge Dev
2 parents 43ff994 + b55d4b8 commit c285d74

14 files changed

+269
-91
lines changed

.github/workflows/ai-pr-review.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: AI PR Review (Incremental)
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
ai-review:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Install dependencies
22+
run: |
23+
pip install requests jq
24+
25+
- name: Get incremental diff
26+
id: diff
27+
run: |
28+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
29+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
30+
git diff $BASE_SHA...$HEAD_SHA > pr.diff
31+
32+
if [ ! -s pr.diff ]; then
33+
echo "EMPTY_DIFF=true" >> $GITHUB_ENV
34+
fi
35+
36+
- name: Run OpenAI review
37+
if: env.EMPTY_DIFF != 'true'
38+
run: |
39+
python3 << 'EOF'
40+
import os, json, requests
41+
42+
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
43+
DIFF = open("pr.diff").read()[:15000]
44+
45+
prompt = f"""
46+
Review this incremental pull request diff.
47+
48+
Tasks:
49+
1. Write a concise PR summary (overall risks, design issues).
50+
2. Provide inline review comments with:
51+
- file
52+
- line
53+
- comment
54+
55+
Respond ONLY in valid JSON with this schema:
56+
{{
57+
"summary": "string",
58+
"comments": [
59+
{{
60+
"file": "path/to/file",
61+
"line": 123,
62+
"comment": "text"
63+
}}
64+
]
65+
}}
66+
67+
Diff:
68+
{DIFF}
69+
"""
70+
71+
response = requests.post(
72+
"https://api.openai.com/v1/responses",
73+
headers={
74+
"Authorization": f"Bearer {OPENAI_API_KEY}",
75+
"Content-Type": "application/json"
76+
},
77+
json={
78+
"model": "gpt-4.1-mini",
79+
"input": prompt,
80+
"temperature": 0.2
81+
}
82+
)
83+
84+
data = response.json()
85+
text = data["output"][0]["content"][0]["text"]
86+
87+
parsed = json.loads(text)
88+
with open("ai_output.json", "w") as f:
89+
json.dump(parsed, f, indent=2)
90+
EOF
91+
env:
92+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
93+
94+
- name: Post PR summary comment
95+
if: env.EMPTY_DIFF != 'true'
96+
run: |
97+
SUMMARY=$(jq -r '.summary' ai_output.json)
98+
gh pr comment ${{ github.event.pull_request.number }} \
99+
--body "## 🤖 AI PR Review Summary\n\n$SUMMARY"
100+
env:
101+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
103+
- name: Post inline review comments
104+
if: env.EMPTY_DIFF != 'true'
105+
run: |
106+
jq -c '.comments[]' ai_output.json | while read c; do
107+
FILE=$(echo $c | jq -r '.file')
108+
LINE=$(echo $c | jq -r '.line')
109+
COMMENT=$(echo $c | jq -r '.comment')
110+
111+
gh api \
112+
repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments \
113+
-f body="$COMMENT" \
114+
-f commit_id="${{ github.event.pull_request.head.sha }}" \
115+
-f path="$FILE" \
116+
-f line="$LINE" \
117+
-f side="RIGHT"
118+
done
119+
env:
120+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/mlperf-inference-resnet50.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.12", "3.11", "3.8"]
18+
python-version: ["3.13", "3.11", "3.9"]
1919
on: [ubuntu-latest, macos-latest, windows-latest]
2020
backend: [ "onnxruntime", "tf" ]
2121
implementation: [ "python", "cpp" ]
@@ -24,6 +24,8 @@ jobs:
2424
implementation: cpp
2525
- on: windows-latest
2626
implementation: cpp
27+
- on: windows-latest
28+
python-version: 3.13
2729
runs-on: "${{ matrix.on }}"
2830
steps:
2931
- uses: actions/checkout@v4

.github/workflows/test-mlc-core-actions.yaml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: ["3.12", "3.8"]
20+
python-version: ["3.14", "3.8"]
2121
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
2222
exclude:
2323
- os: windows-latest
@@ -152,13 +152,7 @@ jobs:
152152
mlc add repo https://github.com/mlcommons/inference
153153
mlc add repo https://mygit.com/myrepo
154154
155-
' Disabled now as MLCFlow automatically deletes corrupted entries
156-
- name: Test 13 - rm repo where we have a corrupt entry
157-
run: |
158-
rm -r $HOME/MLC/repos/mlcommons@mlperf-automations
159-
mlc rm repo mlcommons@mlperf-automations
160-
mlc pull repo mlcommons@mlperf-automations --branch=dev
161-
'
155+
162156
- name: Test 14 - add script - Add a new MLC script
163157
run: |
164158
mlc add script my-script-1 --tags=my,new-tags-1
@@ -232,7 +226,7 @@ jobs:
232226
strategy:
233227
fail-fast: false
234228
matrix:
235-
python-version: ["3.12", "3.8"]
229+
python-version: ["3.14", "3.8"]
236230
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
237231
exclude:
238232
- os: windows-latest
@@ -286,7 +280,7 @@ jobs:
286280
strategy:
287281
fail-fast: false
288282
matrix:
289-
python-version: ["3.12", "3.8"]
283+
python-version: ["3.14", "3.8"]
290284
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
291285

292286
steps:
@@ -372,7 +366,7 @@ jobs:
372366
strategy:
373367
fail-fast: false
374368
matrix:
375-
python-version: ["3.13", "3.8"]
369+
python-version: ["3.14", "3.8"]
376370
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
377371
action: ["mlcr", "mlce", "mlct"]
378372

@@ -395,5 +389,5 @@ jobs:
395389
python -m pip install .
396390
- name: MLC ${{matrix.action}} script
397391
run: |
398-
mlcp mlcommons@mlperf-automations
392+
mlcp mlcommons@mlperf-automations --branch=dev
399393
${{matrix.action}} detect,cpu

.github/workflows/test-mlc-docker-core.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: ["3.13", "3.8"]
19+
python-version: ["3.14", "3.9"]
2020
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
2121
exclude:
2222
- os: windows-latest

.github/workflows/test-mlc-podman.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: ["3.12", "3.8"]
21+
python-version: ["3.14", "3.9"]
2222
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
2323
exclude:
2424
- os: windows-latest

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.14
1+
1.1.18

mlc/action.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ def load_repos(self):
165165
logger.error(f"Error reading file: {e}")
166166
return None
167167

168+
def get_index(self):
169+
if self._index is None:
170+
self._index = Index(self.repos_path, self.repos)
171+
return self._index
168172

169173
def __init__(self):
170174
setup_logging(log_path=os.getcwd(), log_file='.mlc-log.txt')
@@ -200,7 +204,7 @@ def __init__(self):
200204

201205
self.repos = self.load_repos_and_meta()
202206
#logger.info(f"In Action class: {self.repos_path}")
203-
self.index = Index(self.repos_path, self.repos)
207+
self._index = None
204208

205209

206210
def add(self, i):
@@ -380,7 +384,7 @@ def rm(self, i):
380384

381385
logger.info(f"{target_name} item: {item_path} has been successfully removed")
382386

383-
self.index.rm(item_meta, target_name, item_path)
387+
self.get_index().rm(item_meta, target_name, item_path)
384388

385389
return {
386390
"return": 0,
@@ -413,7 +417,7 @@ def save_new_meta(self, i, item_id, item_name, target_name, item_path, repo):
413417
if save_result["return"] > 0:
414418
return save_result
415419

416-
self.index.add(item_meta, target_name, item_path, repo)
420+
self.get_index().add(item_meta, target_name, item_path, repo)
417421
return {'return': 0}
418422

419423
def update(self, i):
@@ -482,7 +486,7 @@ def update(self, i):
482486
# Save the updated meta back to the item
483487
item.meta = meta
484488
save_result = utils.save_json(item_meta_path, meta=meta)
485-
self.index.update(meta, target_name, item.path, item.repo)
489+
self.get_index().update(meta, target_name, item.path, item.repo)
486490

487491
return {'return': 0, 'message': f"Tags updated successfully for {len(found_items)} item(s).", 'list': found_items }
488492

@@ -641,13 +645,13 @@ def mv(self, run_args):
641645
#Put the src uid to the destination path
642646
dest.meta['uid'] = src.meta['uid']
643647
dest._save_meta()
644-
self.index.update(dest.meta, target_name, dest.path, dest.repo)
648+
self.get_index().update(dest.meta, target_name, dest.path, dest.repo)
645649
logger.info(f"""Item with uid {dest.meta['uid']} successfully moved from {src.path} to {dest.path}""")
646650

647651
return {'return': 0, 'src': src, 'dest': dest}
648652

649653
def search(self, i):
650-
indices = self.index.indices
654+
indices = self.get_index().indices
651655
target = i.get('target_name', self.action_type)
652656
target_index = indices.get(target)
653657
result = []

mlc/cache_action.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .action import Action
22
import os
33
import json
4+
import time
45
from . import utils
56
from .logger import logger
67

@@ -59,7 +60,7 @@ def search(self, i):
5960
continue # skip item
6061
'''
6162

62-
expiration_time = item_meta.get('expiration_time')
63+
expiration_time = item_meta.get('cache_expiration')
6364
if expiration_time is not None and expiration_time < time.time():
6465
continue # skip expired item
6566

@@ -158,6 +159,42 @@ def show(self, run_args):
158159

159160
return {'return': 0}
160161

162+
163+
164+
def prune(self, args):
165+
"""
166+
####################################################################################################################
167+
Target: Cache
168+
Action: Prune
169+
####################################################################################################################
170+
171+
Prune all expired cached items
172+
173+
Example Command:
174+
175+
mlc prune cache
176+
177+
"""
178+
self.action_type = "cache"
179+
run_args = {"fetch_all": True} # to fetch the details of all the caches generated
180+
181+
res = self.search(run_args)
182+
if res['return'] > 0:
183+
return res
184+
185+
for item in res['list']:
186+
expiration_time = item.meta.get('cache_expiration')
187+
if expiration_time is not None and expiration_time < time.time():
188+
ii = {}
189+
ii['f'] = True
190+
ii['item'] = item.meta.get('uid')
191+
if ii['item']:
192+
self.rm(ii)
193+
194+
return {'return': 0}
195+
196+
197+
161198
def list(self, args):
162199
"""
163200
####################################################################################################################

0 commit comments

Comments
 (0)