|
| 1 | +name: Run Upgraider Experiment |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + model: |
| 7 | + description: "Model to use for fixing (gpt-3.5, gpt-4)" |
| 8 | + type: string |
| 9 | + default: "gpt-3.5" |
| 10 | + useModelOnly: |
| 11 | + description: "Run experiment with no external sources" |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + useDoc: |
| 15 | + description: "Run experiment with references from Documentation/release notes" |
| 16 | + type: boolean |
| 17 | + default: true |
| 18 | + compareTo: |
| 19 | + description: "Run number of previous run to compare to (leave empty to skip comparison)" |
| 20 | + default: "" |
| 21 | + simthreshold: |
| 22 | + description: "Similarity threshold for retrieval" |
| 23 | + default: "0" # include all info |
| 24 | + debug_enabled: |
| 25 | + type: boolean |
| 26 | + description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)" |
| 27 | + default: false |
| 28 | +jobs: |
| 29 | + setup: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + outputs: |
| 32 | + libraries: "${{ steps.parse_libraries.outputs.libraries }}" |
| 33 | + model: "${{ github.event.inputs.model }}" |
| 34 | + useModelOnly: "${{ github.event.inputs.useModelOnly || false }}" |
| 35 | + useDoc: "${{ github.event.inputs.useDoc || true }}" |
| 36 | + threshold: "${{ github.event.inputs.simthreshold || 0 }}" |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + |
| 40 | + - uses: actions/setup-python@v4 |
| 41 | + with: |
| 42 | + python-version: '3.10' |
| 43 | + |
| 44 | + - run: | |
| 45 | + pip install -r requirements.txt |
| 46 | + python setup.py develop |
| 47 | +
|
| 48 | + - id: parse_libraries |
| 49 | + run: | |
| 50 | + libraries=$(python ${GITHUB_WORKSPACE}/src/benchmark/list_libraries.py) |
| 51 | + echo "got libraries $libraries" |
| 52 | + echo "libraries=$libraries" >> $GITHUB_OUTPUT |
| 53 | +
|
| 54 | + benchmark: |
| 55 | + needs: |
| 56 | + - setup |
| 57 | + runs-on: ubuntu-latest |
| 58 | + continue-on-error: true |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: |
| 62 | + library: ${{ fromJson(needs.setup.outputs.libraries) }} |
| 63 | + steps: |
| 64 | + - name: Checkout github repo (+ download lfs dependencies) |
| 65 | + uses: actions/checkout@v3 |
| 66 | + with: |
| 67 | + lfs: true |
| 68 | + |
| 69 | + - name: Pull LFS objects |
| 70 | + run: git lfs pull |
| 71 | + |
| 72 | + - uses: actions/setup-python@v4 |
| 73 | + with: |
| 74 | + python-version: '3.10' |
| 75 | + |
| 76 | + - name: Install dependencies |
| 77 | + run: | |
| 78 | + pip install -r requirements.txt |
| 79 | + python setup.py develop |
| 80 | + |
| 81 | + - name: Setup scratch venv |
| 82 | + run: | |
| 83 | + curr_dir=`pwd` |
| 84 | + SCRATCH_VENV="$curr_dir/../scratchvenv" |
| 85 | + echo "SCRATCH_VENV=$SCRATCH_VENV" >> $GITHUB_ENV |
| 86 | + mkdir $SCRATCH_VENV |
| 87 | + cd $SCRATCH_VENV |
| 88 | + python -m venv .venv |
| 89 | +
|
| 90 | + - name: Setup tmate session |
| 91 | + uses: mxschmitt/action-tmate@v3 |
| 92 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} |
| 93 | + |
| 94 | + - name: Run example update with no sources |
| 95 | + if: ${{ github.event.inputs.useModelOnly == 'true' }} |
| 96 | + env: |
| 97 | + OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" |
| 98 | + OPENAI_ORG: "${{ secrets.OPENAI_ORG }}" |
| 99 | + GPT4_ENDPOINT: ${{ secrets.GPT4_ENDPOINT }} |
| 100 | + GPT4_AUTH_HEADERS: ${{ secrets.GPT4_AUTH_HEADERS }} |
| 101 | + run: | |
| 102 | + library_name=${{ matrix.library.name }} |
| 103 | + curr_dir=`pwd` |
| 104 | + outputdir="$curr_dir/results/$library_name/modelonly" |
| 105 | + mkdir -p $outputdir |
| 106 | + python src/upgraider/fix_lib_examples.py \ |
| 107 | + --libpath ${{ matrix.library.path }} \ |
| 108 | + --outputDir $outputdir \ |
| 109 | + --dbsource modelonly \ |
| 110 | + --threshold ${{ needs.setup.outputs.threshold }} \ |
| 111 | + --model ${{ needs.setup.outputs.model }} \ |
| 112 | +
|
| 113 | + - name: Run example update with doc sources |
| 114 | + if: ${{ needs.setup.outputs.useDoc == 'true' }} |
| 115 | + env: |
| 116 | + OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" |
| 117 | + OPENAI_ORG: "${{ secrets.OPENAI_ORG }}" |
| 118 | + GPT4_ENDPOINT: ${{ secrets.GPT4_ENDPOINT }} |
| 119 | + GPT4_AUTH_HEADERS: ${{ secrets.GPT4_AUTH_HEADERS }} |
| 120 | + run: | |
| 121 | + library_name=${{ matrix.library.name }} |
| 122 | + curr_dir=`pwd` |
| 123 | + outputdir="$curr_dir/results/$library_name/doc" |
| 124 | + mkdir -p $outputdir |
| 125 | + python src/upgraider/fix_lib_examples.py \ |
| 126 | + --libpath ${{ matrix.library.path }} \ |
| 127 | + --outputDir $outputdir \ |
| 128 | + --dbsource doc \ |
| 129 | + --threshold ${{ needs.setup.outputs.threshold }} \ |
| 130 | + --model ${{ needs.setup.outputs.model }} \ |
| 131 | +
|
| 132 | + - name: Zip up results |
| 133 | + run: | |
| 134 | + zip -r results.zip results |
| 135 | +
|
| 136 | + - name: Upload artifacts |
| 137 | + uses: actions/upload-artifact@v3 |
| 138 | + with: |
| 139 | + name: results-${{ matrix.library.name }} |
| 140 | + path: "results.zip" |
| 141 | + |
| 142 | + combine_output: |
| 143 | + name: Combine output from all benchmarks |
| 144 | + needs: |
| 145 | + - benchmark |
| 146 | + runs-on: ubuntu-latest |
| 147 | + steps: |
| 148 | + - name: Download output zips |
| 149 | + uses: actions/download-artifact@v3 |
| 150 | + |
| 151 | + - name: Combine output zips |
| 152 | + run: | |
| 153 | + mkdir results |
| 154 | + for zip in results-*/results.zip |
| 155 | + do |
| 156 | + unzip -oq $zip |
| 157 | + done |
| 158 | + zip -r results.zip results |
| 159 | + - name: Upload combined output files |
| 160 | + uses: actions/upload-artifact@v3 |
| 161 | + with: |
| 162 | + name: results-all |
| 163 | + path: results.zip |
| 164 | + |
| 165 | + generate-report: |
| 166 | + needs: |
| 167 | + - combine_output |
| 168 | + runs-on: ubuntu-latest |
| 169 | + steps: |
| 170 | + - uses: actions/checkout@v3 |
| 171 | + |
| 172 | + - uses: actions/setup-python@v4 |
| 173 | + with: |
| 174 | + python-version: '3.10' |
| 175 | + |
| 176 | + - name: Install dependencies |
| 177 | + run: | |
| 178 | + pip install -r requirements.txt |
| 179 | + python setup.py develop |
| 180 | +
|
| 181 | + - name: Download artifacts for this run |
| 182 | + uses: actions/download-artifact@v3 |
| 183 | + with: |
| 184 | + name: results-all |
| 185 | + path: results |
| 186 | + |
| 187 | + - name: Download artifacts for comparison run |
| 188 | + if: ${{ github.event.inputs.compareTo != '' }} |
| 189 | + uses: dawidd6/action-download-artifact@v2 |
| 190 | + with: |
| 191 | + run_number: ${{ github.event.inputs.compareTo }} |
| 192 | + name: results-all |
| 193 | + path: baseline |
| 194 | + |
| 195 | + - name: Setup tmate session |
| 196 | + uses: mxschmitt/action-tmate@v3 |
| 197 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} |
| 198 | + |
| 199 | + - name: Generate report |
| 200 | + run: | |
| 201 | + cd results |
| 202 | + unzip results.zip |
| 203 | + cd .. |
| 204 | + if [ -d baseline ]; then |
| 205 | + cd baseline |
| 206 | + unzip results.zip |
| 207 | + cd .. |
| 208 | + python ${GITHUB_WORKSPACE}/src/benchmark/parse_reports.py --outputdir results/results --baselinedir baseline/results > $GITHUB_STEP_SUMMARY |
| 209 | + else |
| 210 | + python ${GITHUB_WORKSPACE}/src/benchmark/parse_reports.py --outputdir results/results > $GITHUB_STEP_SUMMARY |
| 211 | + fi |
0 commit comments