-
Notifications
You must be signed in to change notification settings - Fork 59
Introducing CI workflow for examples #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Olive Examples CI | Setup Composite Workflow for CPU runs | ||
| description: "Composite action to setup environment for CPU workflows" | ||
|
|
||
| inputs: | ||
| shell: | ||
| description: "Shell to use." | ||
| required: true | ||
| type: choice | ||
| options: [ "bash", "cmd" ] | ||
|
|
||
| python_version: | ||
| description: "Python version to use." | ||
| required: true | ||
|
|
||
| requirements_file: | ||
| description: "Name/Path of the requirement's file." | ||
| required: true | ||
|
|
||
| hf_cache_key: | ||
| description: "Huggingface cache key to use." | ||
| required: true | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Setup python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ inputs.python_version }} | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| requirements.txt | ||
| ${{ inputs.requirements_file }} | ||
|
|
||
| - name: Install requirements | ||
| if: ${{ inputs.requirements_file }} | ||
| shell: ${{ inputs.shell }} | ||
| run: python -m pip install -r ${{ inputs.requirements_file }} | ||
|
|
||
| - name: Setup HF Cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ env.HF_HOME }} | ||
| key: ${{ inputs.hf_cache_key }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: Olive Examples CI | Setup Composite Workflow for CUDA runs | ||
| description: "Composite action to setup environment for CUDA workflows" | ||
|
|
||
| inputs: | ||
| python_version: | ||
| description: "Python version to use." | ||
| required: true | ||
|
|
||
| requirements_file: | ||
| description: "Name/Path of the requirement's file." | ||
| required: true | ||
|
|
||
| hf_cache_key: | ||
| description: "Huggingface cache key to use." | ||
| required: true | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Setup python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ inputs.python_version }} | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| requirements.txt | ||
| ${{ inputs.requirements_file }} | ||
|
|
||
| - name: Install requirements | ||
| if: ${{ inputs.requirements_file }} | ||
| shell: ${{ inputs.shell }} | ||
| run: python -m pip install -r ${{ inputs.requirements_file }} | ||
|
|
||
| - name: Setup HF Cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ env.HF_HOME }} | ||
| key: ${{ inputs.hf_cache_key }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| """ | ||
| Script to scan the input directory for files with name "olive_ci.json" | ||
| and generate output that can be set as strategy matrix for github job. | ||
|
|
||
| Example: | ||
| python generate_matrix.py <input directory> <ubuntu|windows> <cpu|cuda> | ||
| """ | ||
| import json | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| _defaults = { | ||
| "requirements_file": "", | ||
| } | ||
|
|
||
| dirpath = Path(sys.argv[1]) | ||
| os = sys.argv[2] | ||
| device = sys.argv[3] | ||
|
|
||
| examples = [] | ||
| for filepath in dirpath.rglob("olive_ci.json"): | ||
| with filepath.open() as strm: | ||
| for config in json.load(strm): | ||
| if config["os"] == os and config["device"] == device: | ||
| config["name"] = f"{filepath.parent.name} | {config['name']} | {os} | {device}" | ||
| config["path"] = str(filepath) | ||
| config["cwd"] = str(filepath.parent.relative_to(dirpath)) | ||
|
|
||
| for key, value in _defaults.items(): | ||
| if key not in config: | ||
| config[key] = value | ||
|
|
||
| examples.append(config) | ||
|
|
||
| matrix = {"include": examples} | ||
| output = json.dumps(matrix) | ||
| print(output) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| name: main | ||
| description: "CI workflow for Olive Examples" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| env: | ||
| PYTHON_VERSION: "3.10" | ||
| HF_HOME: ${{ github.workspace }}/.cache/huggingface | ||
| HUGGING_FACE_HUB_TOKEN: ${{ secrets.HUGGING_FACE_HUB_TOKEN }} | ||
|
|
||
| jobs: | ||
| generate-matrix: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| ubuntu-cpu-matrix: ${{ steps.ubuntu-gen-cpu-matrix.outputs.ubuntu_cpu_matrix }} | ||
| ubuntu-cuda-matrix: ${{ steps.ubuntu-gen-cuda-matrix.outputs.ubuntu_cuda_matrix }} | ||
| windows-cpu-matrix: ${{ steps.windows-gen-cpu-matrix.outputs.windows_cpu_matrix }} | ||
| windows-cuda-matrix: ${{ steps.windows-gen-cuda-matrix.outputs.windows_cuda_matrix }} | ||
|
|
||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VERSION }} | ||
|
|
||
| - name: Scan & generate matrix (Ubuntu + CPU) | ||
| id: ubuntu-gen-cpu-matrix | ||
| run: | | ||
| matrix=$(python .github/scripts/generate_matrix.py . ubuntu cpu) | ||
| echo "ubuntu_cpu_matrix=$matrix" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Scan & generate matrix (Ubuntu + CUDA) | ||
| id: ubuntu-gen-cuda-matrix | ||
| run: | | ||
| matrix=$(python .github/scripts/generate_matrix.py . ubuntu cuda) | ||
| echo "ubuntu_cuda_matrix=$matrix" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Scan & generate matrix (Windows + CPU) | ||
| id: windows-gen-cpu-matrix | ||
| run: | | ||
| matrix=$(python .github/scripts/generate_matrix.py . windows cpu) | ||
| echo "windows_cpu_matrix=$matrix" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Scan & generate matrix (Windows + CUDA) | ||
| id: windows-gen-cuda-matrix | ||
| run: | | ||
| matrix=$(python .github/scripts/generate_matrix.py . windows cuda) | ||
| echo "windows_cuda_matrix=$matrix" >> $GITHUB_OUTPUT | ||
|
|
||
| ubuntu-cpu-examples: | ||
| needs: generate-matrix | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJson(needs.generate-matrix.outputs.ubuntu-cpu-matrix) }} | ||
| name: ${{ matrix.name }} | ||
| runs-on: [ self-hosted, 1ES.Pool=olive-github-ubuntu2204-cpu ] | ||
|
|
||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Environment | ||
| uses: ./.github/actions/cpu-setup | ||
| with: | ||
| shell: bash | ||
| python_version: ${{ env.PYTHON_VERSION }} | ||
| hf_cache_key: ${{ runner.os }}-${{ matrix.name }}-hf-cache | ||
| requirements_file: ${{ matrix.cwd }}/${{ matrix.requirements_file }} | ||
|
|
||
| - name: Run Command | ||
| working-directory: ${{ github.workspace }}/${{ matrix.cwd }} | ||
| run: ${{ matrix.command }} | ||
|
|
||
| ubuntu-cuda-examples: | ||
| needs: generate-matrix | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJson(needs.generate-matrix.outputs.ubuntu-cuda-matrix) }} | ||
| name: ${{ matrix.name }} | ||
| runs-on: [ self-hosted, 1ES.Pool=olive-github-ubuntu2204-cuda-A10 ] | ||
|
|
||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Environment | ||
| uses: ./.github/actions/cuda-setup | ||
| with: | ||
| shell: bash | ||
| python_version: ${{ env.PYTHON_VERSION }} | ||
| hf_cache_key: ${{ runner.os }}-${{ matrix.name }}-hf-cache | ||
| requirements_file: ${{ matrix.cwd }}/${{ matrix.requirements_file }} | ||
|
|
||
| - name: Run Command | ||
| working-directory: ${{ github.workspace }}/${{ matrix.cwd }} | ||
| run: ${{ matrix.command }} | ||
|
|
||
| windows-cpu-examples: | ||
| needs: generate-matrix | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJson(needs.generate-matrix.outputs.windows-cpu-matrix) }} | ||
| name: ${{ matrix.name }} | ||
| runs-on: [ self-hosted, 1ES.Pool=olive-github-win2022-cpu ] | ||
|
|
||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Environment | ||
| uses: ./.github/actions/cpu-setup | ||
| with: | ||
| shell: cmd | ||
| python_version: ${{ env.PYTHON_VERSION }} | ||
| hf_cache_key: ${{ runner.os }}-${{ matrix.name }}-hf-cache | ||
| requirements_file: ${{ matrix.cwd }}/${{ matrix.requirements_file }} | ||
|
|
||
| - name: Run Command | ||
| working-directory: ${{ github.workspace }}/${{ matrix.cwd }} | ||
| run: ${{ matrix.command }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.