|
| 1 | +name: Examples - APO |
| 2 | +permissions: |
| 3 | + contents: read |
| 4 | +on: |
| 5 | + schedule: |
| 6 | + # Every day at 3 AM UTC+8 |
| 7 | + - cron: '0 19 * * *' |
| 8 | + |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | + repository_dispatch: |
| 12 | + types: [ci-apo, ci-all] |
| 13 | + |
| 14 | +run-name: >- |
| 15 | + ${{ github.event_name == 'repository_dispatch' |
| 16 | + && format( |
| 17 | + 'PR #{0} - Label {1} - {2}', |
| 18 | + github.event.client_payload.pull_number, |
| 19 | + github.event.client_payload.ci_label, |
| 20 | + github.event.client_payload.correlation_id |
| 21 | + ) |
| 22 | + || format('APO - {0}', github.event_name) }} |
| 23 | +
|
| 24 | +jobs: |
| 25 | + apo: |
| 26 | + if: > |
| 27 | + github.event_name != 'repository_dispatch' || |
| 28 | + github.event.action == 'ci-apo' || |
| 29 | + github.event.action == 'ci-all' |
| 30 | + name: APO (Python ${{ matrix.python-version }}, ${{ matrix.setup-script }}) |
| 31 | + # This job is run on GitHub hosted runners rather than self-hosted runners because it needs no GPU. |
| 32 | + runs-on: ubuntu-latest |
| 33 | + timeout-minutes: 30 |
| 34 | + strategy: |
| 35 | + matrix: |
| 36 | + include: |
| 37 | + - python-version: '3.10' |
| 38 | + setup-script: 'legacy' |
| 39 | + - python-version: '3.12' |
| 40 | + setup-script: 'stable' |
| 41 | + - python-version: '3.13' |
| 42 | + setup-script: 'latest' |
| 43 | + fail-fast: false |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.pr_ref || (github.event.pull_request.number && format('refs/pull/{0}/merge', github.event.pull_request.number)) || github.ref }} |
| 48 | + - uses: astral-sh/setup-uv@v7 |
| 49 | + with: |
| 50 | + enable-cache: true |
| 51 | + python-version: ${{ matrix.python-version }} |
| 52 | + - name: Upgrade dependencies (latest) |
| 53 | + run: uv lock --upgrade |
| 54 | + if: matrix.setup-script == 'latest' |
| 55 | + - name: Sync dependencies (latest) |
| 56 | + run: | |
| 57 | + uv sync --frozen --no-default-groups --extra apo \ |
| 58 | + --group dev --group experiment --group agents --group core-stable |
| 59 | + if: matrix.setup-script == 'latest' |
| 60 | + - name: Sync dependencies (stable & legacy) |
| 61 | + run: | |
| 62 | + uv sync --frozen --no-default-groups --extra apo \ |
| 63 | + --group dev --group experiment --group agents --group core-${{ matrix.setup-script }} |
| 64 | + if: matrix.setup-script != 'latest' |
| 65 | + - name: Freeze dependencies |
| 66 | + run: | |
| 67 | + set -ex |
| 68 | + uv pip freeze | tee requirements-freeze.txt |
| 69 | + echo "UV_LOCKED=1" >> $GITHUB_ENV |
| 70 | + echo "UV_NO_SYNC=1" >> $GITHUB_ENV |
| 71 | + - name: Upload dependencies artifact |
| 72 | + uses: actions/upload-artifact@v4 |
| 73 | + with: |
| 74 | + name: dependencies-apo-${{ matrix.python-version }}-${{ matrix.setup-script }} |
| 75 | + path: requirements-freeze.txt |
| 76 | + compression-level: 0 |
| 77 | + |
| 78 | + - name: Launch LiteLLM Proxy |
| 79 | + run: | |
| 80 | + ./scripts/litellm_run.sh |
| 81 | + env: |
| 82 | + AZURE_API_BASE: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_BASE }} |
| 83 | + AZURE_API_KEY: ${{ secrets.AZURE_GROUP_SUBSCRIPTION_API_KEY }} |
| 84 | + |
| 85 | + - name: APO custom algorithm |
| 86 | + run: | |
| 87 | + set -ex |
| 88 | + cd examples/apo |
| 89 | + uv run apo_custom_algorithm_trainer.py | tee _ci_apo.log |
| 90 | + # Check whether the log contains "Best prompt found:" |
| 91 | + grep "Best prompt found:" _ci_apo.log |
| 92 | + env: |
| 93 | + # New versions follow OPENAI_BASE_URL instead of OPENAI_API_BASE |
| 94 | + OPENAI_BASE_URL: http://localhost:12306/ |
| 95 | + OPENAI_API_KEY: dummy |
| 96 | + - name: APO custom algorithm debugger |
| 97 | + run: | |
| 98 | + set -ex |
| 99 | + cd examples/apo |
| 100 | + uv run apo_debug.py --mode runner |
| 101 | + uv run apo_debug.py --mode hook |
| 102 | + uv run apo_debug.py --mode trainer |
| 103 | + env: |
| 104 | + # New versions follow OPENAI_BASE_URL instead of OPENAI_API_BASE |
| 105 | + OPENAI_BASE_URL: http://localhost:12306/ |
| 106 | + OPENAI_API_KEY: dummy |
| 107 | + |
| 108 | + - name: APO built-in algorithm |
| 109 | + run: | |
| 110 | + set -ex |
| 111 | + cd examples/apo |
| 112 | + uv run room_selector_apo.py |
| 113 | + env: |
| 114 | + OPENAI_BASE_URL: http://localhost:12306/ |
| 115 | + OPENAI_API_KEY: dummy |
| 116 | + if: matrix.setup-script != 'legacy' |
0 commit comments