Skip to content

Commit 84e4c7c

Browse files
committed
fix upload
1 parent a5ccd6d commit 84e4c7c

File tree

5 files changed

+56
-30
lines changed

5 files changed

+56
-30
lines changed

.github/workflows/readme.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ jobs:
2727
python -m pip install --upgrade pip
2828
python -m pip install invoke rundoc .
2929
python -m pip install tomli
30+
python -m pip install slack-sdk
3031
- name: Run the README.md
3132
run: invoke readme

.github/workflows/run_benchmark.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Run SDGym Benchmark
22

33
on:
4-
push:
5-
branches:
6-
- issue-425-workflow-sdgym
74
workflow_dispatch:
85
schedule:
96
- cron: '0 5 1 * *'

.github/workflows/upload_benchmark_results.yml

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,80 @@ on:
1515
jobs:
1616
upload-sdgym-benchmark:
1717
runs-on: ubuntu-latest
18+
1819
steps:
1920
- uses: actions/checkout@v4
2021
with:
2122
fetch-depth: 0
23+
2224
- name: Set up latest Python
2325
uses: actions/setup-python@v5
2426
with:
2527
python-version-file: 'pyproject.toml'
28+
2629
- name: Install dependencies
2730
run: |
28-
python -m pip install --upgrade pip
29-
python -m pip install invoke
30-
python -m pip install -e .[dev]
31+
python -m pip install --upgrade pip
32+
python -m pip install -e .[dev]
3133
3234
- name: Upload SDGym Benchmark
3335
env:
3436
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
3537
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3638
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
3739
GITHUB_LOCAL_RESULTS_DIR: ${{ runner.temp }}/sdgym-leaderboard-files
38-
3940
run: |
4041
invoke upload-benchmark-results
41-
- name: Create pull request for SDGym benchmark result
42-
id: create_pr
43-
if: env.SKIP_UPLOAD != 'true'
44-
uses: peter-evans/create-pull-request@v4
45-
with:
46-
token: ${{ secrets.GH_ACCESS_TOKEN }}
47-
commit-message: "Upload SDGym Benchmark Results (${{ env.FOLDER_NAME }})"
48-
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
49-
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
50-
title: "Upload SDGym Benchmark Results - ${{ env.FOLDER_NAME }}"
51-
body: |
52-
This is an **auto-generated PR** for uploading SDGym benchmark latest results.
42+
echo "GITHUB_LOCAL_RESULTS_DIR=$GITHUB_LOCAL_RESULTS_DIR" >> $GITHUB_ENV
43+
44+
- name: Check skip upload flag
45+
run: |
46+
if [ "${SKIP_UPLOAD}" = "true" ]; then
47+
echo "Upload skipped. Exiting workflow."
48+
exit 0
49+
fi
50+
- name: Prepare summary file for PR
51+
run: |
52+
mkdir pr-staging
53+
echo "Looking for: $GITHUB_LOCAL_RESULTS_DIR/${FOLDER_NAME}_summary.csv"
54+
ls -l "$GITHUB_LOCAL_RESULTS_DIR"
55+
cp "$GITHUB_LOCAL_RESULTS_DIR/${FOLDER_NAME}_summary.csv" \
56+
"pr-staging/SDGym_summary_${FOLDER_NAME}.csv"
5357
54-
branch: sdgym-benchmark-upload
55-
branch-suffix: short-commit-hash
56-
base: gatsby-home
58+
- name: Checkout target repo (sdv-dev.github.io)
59+
run: |
60+
git clone https://github.com/sdv-dev/sdv-dev.github.io.git target-repo
61+
cd target-repo
62+
git checkout gatsby-home
63+
- name: Copy summary and create PR
64+
env:
65+
FOLDER_NAME: ${{ env.FOLDER_NAME }}
66+
run: |
67+
cp pr-staging/SDGym_summary_${FOLDER_NAME}.csv target-repo/assets/
68+
69+
cd target-repo
70+
git checkout -b sdgym-benchmark-upload-${FOLDER_NAME}
71+
git config --local user.name "${GITHUB_ACTOR}"
72+
git config --local user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
73+
74+
git add assets/
75+
git commit -m "Upload SDGym Benchmark Summary ($FOLDER_NAME)"
76+
77+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/sdv-dev/sdv-dev.github.io.git
78+
git push origin sdgym-benchmark-upload-${FOLDER_NAME}
79+
80+
gh pr create \
81+
--repo sdv-dev/sdv-dev.github.io \
82+
--head sdgym-benchmark-upload-${FOLDER_NAME} \
83+
--base gatsby-home \
84+
--title "Upload SDGym Benchmark Summary ($FOLDER_NAME)" \
85+
--body "Automated benchmark summary upload" \
86+
--assignee "${{ github.actor }}"
5787
5888
- name: Send Slack notification
59-
if: env.SKIP_UPLOAD != 'true'
6089
env:
6190
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
62-
6391
run: |
6492
invoke notify-sdgym-benchmark-uploaded \
65-
--folder-name ${{ env.FOLDER_NAME }} \
66-
--pr-url "${{ steps.create_pr.outputs.pull-request-url }}"
67-
93+
--folder-name $FOLDER_NAME \
94+
--pr-url "$(gh pr view --json url -q .url)"

sdgym/run_benchmark/upload_benchmark_results.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def upload_results(
9292
)
9393
local_export_dir = os.environ.get('GITHUB_LOCAL_RESULTS_DIR')
9494
if local_export_dir:
95+
os.makedirs(local_export_dir, exist_ok=True)
9596
local_results_writer.write_dataframe(
9697
summary, f'{local_export_dir}/{folder_name}_summary.csv', index=True
9798
)
@@ -106,7 +107,7 @@ def main():
106107
folder_name, s3_client, bucket, prefix = get_result_folder_name_and_s3_vars(
107108
aws_access_key_id, aws_secret_access_key
108109
)
109-
github_env = os.environ.get('GITHUB_ENV')
110+
github_env = os.getenv('GITHUB_ENV')
110111
if upload_already_done(s3_client, bucket, prefix, folder_name):
111112
LOGGER.warning('Benchmark results have already been uploaded. Exiting.')
112113
if github_env:

tests/unit/run_benchmark/test_upload_benchmark_result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def test_main_already_upload(
217217
):
218218
"""Test the `method` when results are already uploaded."""
219219
# Setup
220-
mock_getenv.side_effect = ['my_access_key', 'my_secret_key']
220+
mock_getenv.side_effect = ['my_access_key', 'my_secret_key', None]
221221
mock_get_result_folder_name_and_s3_vars.return_value = (
222222
'run_name',
223223
's3_client',
@@ -251,7 +251,7 @@ def test_main(
251251
):
252252
"""Test the `main` method."""
253253
# Setup
254-
mock_getenv.side_effect = ['my_access_key', 'my_secret_key']
254+
mock_getenv.side_effect = ['my_access_key', 'my_secret_key', None]
255255
mock_get_result_folder_name_and_s3_vars.return_value = (
256256
'run_name',
257257
's3_client',

0 commit comments

Comments
 (0)