Skip to content

Dependency has changed to runpod~=<version> and not runpod==<version> #22

Dependency has changed to runpod~=<version> and not runpod==<version>

Dependency has changed to runpod~=<version> and not runpod==<version> #22

name: CI | Test Worker
# Requires the following secrets:
# - RUNPOD_ENDPOINT: The endpoint of the Runpod API
# - RUNPOD_API_KEY: The API key to authenticate with the Runpod API
# - GH_PAT: A GitHub Personal Access Token with access to the repository
# - GH_ORG: The GitHub organization the repository is in
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
initialize_runner:
runs-on: ubuntu-latest
outputs:
id: ${{ steps.extract_id.outputs.runpod_job_id }}
steps:
- name: Deploy Worker
id: deploy
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.runpod.ai/v2/${{ secrets.RUNPOD_ENDPOINT }}/run"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}
data: '{"input":{"github_pat": "${{ secrets.GH_PAT }}", "github_org":"${{ secrets.GH_ORG }}"}}'
- name: Extract Job ID
id: extract_id
run: |
ID=$(echo '${{ steps.deploy.outputs.response }}' | jq -r '.id')
echo "::set-output name=runpod_job_id::$ID"
run_tests:
needs: initialize_runner
runs-on: runpod
steps:
- uses: actions/checkout@v3
- name: Install System Dependencies
run: /bin/bash builder/packages.sh
- name: Set up Python 3.10.12
uses: actions/setup-python@v4
with:
python-version: "3.10.12"
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install -r builder/requirements.txt
- name: Set Environment Variables
run: |
echo "PYTHONDONTWRITEBYTECODE=1" >> $GITHUB_ENV
echo "PYTHONBUFFERED=1" >> $GITHUB_ENV
- name: Cache Models
run: python builder/cache_models.py
- name: Execute Tests
run: |
python src/rp_handler.py --test_input='{"input": {"prompt": "A happy place."}}'
python src/rp_handler.py --test_input='{"input": {
"prompt": "A happy place.",
"negative_prompt": "A sad place.",
"num_images": 5
}}'
python src/rp_handler.py --test_input='{
"input": {
"prompt": "A happy place.",
"negative_prompt": "A sad place.",
"num_steps": 200,
"seed": 420,
"num_images": 5
}
}'
terminate_runner:
if: always()
needs: [run_tests, initialize_runner]
runs-on: ubuntu-latest
steps:
- name: Get Job Status
id: get_status
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.runpod.ai/v2/${{ secrets.RUNPOD_ENDPOINT }}/status/${{ needs.initialize_runner.outputs.id }}"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}
- name: Parse Status
id: parse_status
run: |
STATUS=$(echo '${{ steps.get_status.outputs.response }}' | jq -r '.status')
echo "::set-output name=status::$STATUS"
- name: Shutdown Worker
if: ${{ steps.parse_status.outputs.status != 'COMPLETED' }}
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.runpod.ai/v2/${{ secrets.RUNPOD_ENDPOINT }}/cancel/${{ needs.initialize_runner.outputs.id }}"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}