feat: inference API cleanup #406
Workflow file for this run
This file contains 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
name: Build and Push Preset Models | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'presets/inference/**' | |
- 'presets/models/supported_models.yaml' | |
push: | |
branches: | |
- main | |
paths: | |
- 'presets/inference/**' | |
- 'presets/models/supported_models.yaml' | |
workflow_dispatch: | |
inputs: | |
image_tag_name: | |
description: 'Image Tag' | |
required: true | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
determine-models: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.affected_models.outputs.matrix }} | |
is_matrix_empty: ${{ steps.check_matrix_empty.outputs.is_empty }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
# This script should output a JSON array of model names | |
- name: Determine Affected Models | |
id: affected_models | |
run: | | |
PR_BRANCH=${{ github.head_ref }} \ | |
python3 .github/workflows/kind-cluster/determine_models.py | |
- name: Print Determined Models | |
run: | | |
echo "Output from affected_models: ${{ steps.affected_models.outputs.matrix }}" | |
- name: Check if Matrix is Empty | |
id: check_matrix_empty | |
run: | | |
if [ "${{ steps.affected_models.outputs.matrix }}" == "[]" ] || [ -z "${{ steps.affected_models.outputs.matrix }}" ]; then | |
echo "is_empty=true" >> $GITHUB_OUTPUT | |
else | |
echo "is_empty=false" >> $GITHUB_OUTPUT | |
fi | |
build-models: | |
needs: determine-models | |
if: needs.determine-models.outputs.is_matrix_empty == 'false' | |
runs-on: [self-hosted, 'hostname:model-server'] | |
strategy: | |
fail-fast: false | |
matrix: | |
model: ${{fromJson(needs.determine-models.outputs.matrix)}} | |
max-parallel: 3 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Check Available Disk Space | |
run: df -h | |
- name: 'Get ACR Info' | |
id: acr_info | |
run: | | |
ACR_NAME="${{ secrets.ACR_AMRT_USERNAME }}" | |
ACR_USERNAME=${{ secrets.ACR_AMRT_USERNAME }} | |
ACR_PASSWORD=${{ secrets.ACR_AMRT_PASSWORD }} | |
echo "ACR_NAME=$ACR_NAME" >> $GITHUB_OUTPUT | |
echo "ACR_USERNAME=$ACR_USERNAME" >> $GITHUB_OUTPUT | |
echo "ACR_PASSWORD=$ACR_PASSWORD" >> $GITHUB_OUTPUT | |
- name: Launch Python Script to Kickoff Build Jobs | |
id: launch_script | |
run: | | |
PR_BRANCH=${{ github.head_ref }} \ | |
ACR_NAME=${{ steps.acr_info.outputs.ACR_NAME }} \ | |
ACR_USERNAME=${{ steps.acr_info.outputs.ACR_USERNAME }} \ | |
ACR_PASSWORD=${{ steps.acr_info.outputs.ACR_PASSWORD }} \ | |
MODEL_NAME=${{ matrix.model.name }} \ | |
MODEL_TYPE=${{matrix.model.type}} \ | |
MODEL_VERSION=${{ matrix.model.version }} \ | |
MODEL_RUNTIME=${{ matrix.model.runtime }} \ | |
MODEL_TAG=${{ matrix.model.tag }} \ | |
python3 .github/workflows/kind-cluster/main.py | |
# Check the exit status of the Python script | |
- name: Check Python Script Status | |
if: ${{ always() }} | |
run: | | |
if [ "${{ steps.launch_script.outcome }}" != "success" ]; then | |
echo "Python script failed to execute successfully." | |
exit 1 # Fail the job | |
else | |
echo "Python script executed successfully." | |
fi | |
# Cleanup Resources | |
- name: Cleanup | |
if: ${{ always() }} | |
run: | | |
kubectl get job --no-headers -o custom-columns=":metadata.name" | grep "^docker-build-job" | xargs -r kubectl delete job | |
kubectl get pods --no-headers -o custom-columns=":metadata.name" | grep "^docker-build-job" | xargs -r kubectl delete pod |