Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/scripts/list_modified_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
def get_file_info(filepath):
with open(filepath, 'r') as file:
content = yaml.safe_load(file)
tests = content.get('tests', [])
needs_pat = content.get('needs_pat', False)
tests = content.get('tests', {})
needs_pat = tests.get('needs_pat', False)
if tests and not needs_pat:
num_tests = len(tests.get('run_inputs', []))
else:
Expand Down
38 changes: 38 additions & 0 deletions .github/scripts/list_modified_scripts_with_secrets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import yaml
import sys
import json
import os


def get_file_info(filepath):
with open(filepath, 'r') as file:
content = yaml.safe_load(file)
tests = content.get('tests', {})
needs_pat = tests.get('needs_pat', False)
if tests and needs_pat:
num_tests = len(tests.get('run_inputs', []))
else:
num_tests = 0
uid = content['uid']
return uid, num_tests


def process_files(files):
filenames = files.split(",")
return [
{
"file": file,
"uid": uid,
"num_run": i
}
for file in filenames if os.path.basename(file) == 'meta.yaml'
for uid, num_tests in [get_file_info(file)]
for i in range(1, num_tests + 1)
]


if __name__ == "__main__":
changed_files = sys.stdin.read().strip()
processed_files = process_files(changed_files)
json_processed_files = json.dumps(processed_files)
print(json_processed_files)
3 changes: 2 additions & 1 deletion .github/workflows/run-tests-on-modified-meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:

process_modified_files:
runs-on: ubuntu-latest
needs: get_modified_files
needs:
- get_modified_files
if: needs.get_modified_files.outputs.processed_files != '[]' && needs.get_modified_files.outputs.processed_files != ''
strategy:
fail-fast: false
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/run_tests_on_modified_meta_with_secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Test script on modified meta (with secret)

on:
pull_request_target:
branches: [ "main", "dev" ]
paths:
- 'script/**meta.yaml'

jobs:
fetch-secret:
runs-on: ubuntu-latest
outputs:
gdrive_secret: ${{ steps.op-load-secret.outputs.GDRIVE_SERVICE_ACCOUNT_KEY }}
steps:
- name: Load secret from 1Password
id: op-load-secret
uses: 1password/load-secrets-action@v2
with:
export-env: false
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
GDRIVE_SERVICE_ACCOUNT_KEY: op://7basd2jirojjckncf6qnq3azai/bzbaco3uxoqs2rcyu42rvuccga/credential

get_modified_files:
runs-on: ubuntu-latest
outputs:
processed_files: ${{ steps.filter-modified-files.outputs.processed_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: pip install pyyaml

- name: Fetch base branch
run: |
git fetch origin +refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}

- name: Get list of changed files
id: modified-files
run: |
git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD > changed_files.txt
files=$(paste -sd, changed_files.txt)
echo "files=$files" >> $GITHUB_OUTPUT

- name: Filter changed files
id: filter-modified-files
env:
FILES: ${{ steps.modified-files.outputs.files }}
run: |
processed=$(echo "$FILES" | python3 .github/scripts/list_modified_scripts_with_secrets.py)
echo "processed_files<<EOF" >> $GITHUB_OUTPUT
echo "$processed" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Debug processed_files output
run: |
echo "Processed files output:"
echo "${{ steps.filter-modified-files.outputs.processed_files }}"

process_modified_files:
needs:
- get_modified_files
- fetch-secret
runs-on: ubuntu-latest
if: needs.get_modified_files.outputs.processed_files != '[]'
strategy:
fail-fast: false
matrix:
file_info: ${{ fromJSON(needs.get_modified_files.outputs.processed_files) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set RCLONE Service account env var from secret
shell: bash
run: |
echo "::add-mask::${{ needs.fetch-secret.outputs.gdrive_secret }}"
echo "RCLONE_CONFIG_MLC_COGNATA_SERVICE_ACCOUNT_CREDENTIALS=${{ needs.fetch-secret.outputs.gdrive_secret }}" >> $GITHUB_ENV
echo "RCLONE_CONFIG_MLC_NUSCENES_SERVICE_ACCOUNT_CREDENTIALS=${{ needs.fetch-secret.outputs.gdrive_secret }}" >> $GITHUB_ENV

- name: Process meta.yaml file
run: |
echo "Processing ${{ matrix.file_info.file }} (run #${{ matrix.file_info.num_run }})"
pip install mlcflow
mlc pull repo ${{ github.event.pull_request.head.repo.html_url }} --branch=${{ github.event.pull_request.head.ref }}
mlc test script ${{ matrix.file_info.uid }} --test_input_index=${{ matrix.file_info.num_run }} --docker_mlc_repo=${{ github.event.pull_request.head.repo.html_url }} --docker_mlc_repo_branch=${{ github.event.pull_request.head.ref }} --quiet
2 changes: 2 additions & 0 deletions script/app-mlperf-inference-mlcommons-python/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1307,10 +1307,12 @@ variations:
MLC_MLPERF_USE_MLCOMMONS_RUN_SCRIPT: "yes"
deps:
- tags: get,generic-python-lib,_opencv-python
version_max: "4.10.0.82"
- tags: get,generic-sys-util,_libgl
- tags: get,generic-python-lib,_numpy
names:
- numpy
version_max: "1.26.4"
- tags: get,generic-python-lib,_pycocotools
prehook_deps:
- tags: get,generic-python-lib,_protobuf
Expand Down
1 change: 1 addition & 0 deletions script/get-ml-model-abtf-ssd-pytorch/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ variations:
env:
MLC_DOWNLOAD_SRC: mlcommons
tests:
needs_pat: true
run_inputs:
- variations_list:
- onnx,rclone,mlc,dry-run
Expand Down
2 changes: 2 additions & 0 deletions script/get-ml-model-bevformer/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
- get
- ml-model
- bevformer
- get-ml-model-bevformer
uid: 438a053f666443bd
new_env_keys:
- MLC_ML_MODEL_BEVFORMER_PATH
Expand Down Expand Up @@ -75,6 +76,7 @@ variations:
env:
MLC_DOWNLOAD_EXTRA_OPTIONS: --dry-run
tests:
needs_pat: true
run_inputs:
- variations_list:
- onnx,rclone,mlc,dry-run
Expand Down
1 change: 1 addition & 0 deletions script/get-ml-model-deeplabv3_plus/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ variations:
env:
MLC_DOWNLOAD_EXTRA_OPTIONS: --dry-run
tests:
needs_pat: true
run_inputs:
- variations_list:
- onnx,rclone,mlc,dry-run
Expand Down
Loading