Skip to content

Commit c33f815

Browse files
committed
Apply the same logic to apple perf workflow
1 parent def9231 commit c33f815

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

.github/workflows/apple-perf.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,30 @@ jobs:
101101

102102
- name: Prepare the spec
103103
shell: bash
104+
env:
105+
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
104106
working-directory: extension/benchmark/apple/Benchmark
105107
run: |
106108
set -eux
107109
108-
echo "DEBUG: ${{ matrix.model }}"
109110
# The model will be exported in the next step to this S3 path
110111
MODEL_PATH="https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.config }}/model.zip"
111112
# We could write a script to properly use jinja here, but there is only one variable,
112113
# so let's just sed it
113114
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' default-ios-device-farm-appium-test-spec.yml.j2
115+
116+
BENCHMARK_CONFIG_ID="${{ matrix.model }}_${{ matrix.config }}"
117+
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
118+
# later by the upload script
119+
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' default-ios-device-farm-appium-test-spec.yml.j2
120+
114121
cp default-ios-device-farm-appium-test-spec.yml.j2 default-ios-device-farm-appium-test-spec.yml
115122
# Just print the test spec for debugging
116123
cat default-ios-device-farm-appium-test-spec.yml
117124
125+
# Save the benchmark configs so that we can use it later in the dashboard
126+
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
127+
118128
- name: Upload the spec
119129
uses: seemethere/upload-artifact-s3@v5
120130
with:
@@ -125,6 +135,16 @@ jobs:
125135
if-no-files-found: error
126136
path: extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
127137

138+
- name: Update the benchmark configs
139+
uses: seemethere/upload-artifact-s3@v5
140+
with:
141+
s3-bucket: gha-artifacts
142+
s3-prefix: |
143+
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
144+
retention-days: 1
145+
if-no-files-found: error
146+
path: extension/benchmark/apple/Benchmark/${{ matrix.model }}_${{ matrix.config }}.json
147+
128148
export-models:
129149
name: export-models
130150
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -481,6 +501,18 @@ jobs:
481501
482502
ls -lah artifacts
483503
504+
- name: Download the list of benchmark configs from S3
505+
env:
506+
BENCHMARK_CONFIGS_DIR: s3://gha-artifacts/${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
507+
shell: bash
508+
run: |
509+
set -eux
510+
mkdir -p benchmark-configs
511+
pushd benchmark-configs
512+
${CONDA_RUN} aws s3 sync "${BENCHMARK_CONFIGS_DIR}" .
513+
popd
514+
ls -lah benchmark-configs
515+
484516
- name: Extract the benchmark results JSON
485517
shell: bash
486518
run: |
@@ -498,7 +530,8 @@ jobs:
498530
--head-branch ${{ github.head_ref || github.ref_name }} \
499531
--workflow-name "${{ github.workflow }}" \
500532
--workflow-run-id ${{ github.run_id }} \
501-
--workflow-run-attempt ${{ github.run_attempt }}
533+
--workflow-run-attempt ${{ github.run_attempt }} \
534+
--benchmark-configs benchmark-configs
502535
done
503536
504537
for SCHEMA in v2 v3; do

extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ phases:
1010
# The pre-test phase includes commands that setup your test environment.
1111
pre_test:
1212
commands:
13+
# Print this so that the upload script can read and process the benchmark config
14+
- echo "The benchmark config is {{ benchmark_config_id }}"
15+
1316
# Download the model from S3
1417
- curl -s --fail '{{ model_path }}' -o model.zip
1518
- unzip model.zip && ls -la

0 commit comments

Comments
 (0)