diff --git a/.github/scripts/list_modified_files.py b/.github/scripts/list_modified_files.py index c7acd1410..282cc0484 100644 --- a/.github/scripts/list_modified_files.py +++ b/.github/scripts/list_modified_files.py @@ -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: diff --git a/.github/scripts/list_modified_scripts_with_secrets.py b/.github/scripts/list_modified_scripts_with_secrets.py new file mode 100644 index 000000000..108a2d402 --- /dev/null +++ b/.github/scripts/list_modified_scripts_with_secrets.py @@ -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) diff --git a/.github/workflows/run-tests-on-modified-meta.yml b/.github/workflows/run-tests-on-modified-meta.yml index b4d86b435..e2dd3b8f2 100644 --- a/.github/workflows/run-tests-on-modified-meta.yml +++ b/.github/workflows/run-tests-on-modified-meta.yml @@ -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 diff --git a/.github/workflows/run_tests_on_modified_meta_with_secrets.yml b/.github/workflows/run_tests_on_modified_meta_with_secrets.yml new file mode 100644 index 000000000..4c8a9deac --- /dev/null +++ b/.github/workflows/run_tests_on_modified_meta_with_secrets.yml @@ -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<> $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 diff --git a/script/app-mlperf-inference-mlcommons-python/meta.yaml b/script/app-mlperf-inference-mlcommons-python/meta.yaml index d01b04c37..a7d5d776b 100644 --- a/script/app-mlperf-inference-mlcommons-python/meta.yaml +++ b/script/app-mlperf-inference-mlcommons-python/meta.yaml @@ -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 diff --git a/script/get-ml-model-abtf-ssd-pytorch/meta.yaml b/script/get-ml-model-abtf-ssd-pytorch/meta.yaml index 017acec37..54ea9e096 100644 --- a/script/get-ml-model-abtf-ssd-pytorch/meta.yaml +++ b/script/get-ml-model-abtf-ssd-pytorch/meta.yaml @@ -253,6 +253,7 @@ variations: env: MLC_DOWNLOAD_SRC: mlcommons tests: + needs_pat: true run_inputs: - variations_list: - onnx,rclone,mlc,dry-run diff --git a/script/get-ml-model-bevformer/meta.yaml b/script/get-ml-model-bevformer/meta.yaml index 4c877ed68..509190518 100644 --- a/script/get-ml-model-bevformer/meta.yaml +++ b/script/get-ml-model-bevformer/meta.yaml @@ -6,6 +6,7 @@ tags: - get - ml-model - bevformer +- get-ml-model-bevformer uid: 438a053f666443bd new_env_keys: - MLC_ML_MODEL_BEVFORMER_PATH @@ -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 diff --git a/script/get-ml-model-deeplabv3_plus/meta.yaml b/script/get-ml-model-deeplabv3_plus/meta.yaml index 66215eb09..455b24566 100644 --- a/script/get-ml-model-deeplabv3_plus/meta.yaml +++ b/script/get-ml-model-deeplabv3_plus/meta.yaml @@ -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