Skip to content

Commit 22b6282

Browse files
Update huggingface dataset from CI
1 parent cbad25a commit 22b6282

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: uv run pytest tests
2626

2727
build-cpu:
28-
needs: test
28+
needs: [test]
2929
uses: ./.github/workflows/build.yml
3030
with:
3131
base: ubuntu:24.04
@@ -37,7 +37,7 @@ jobs:
3737
id-token: write
3838

3939
build-cuda:
40-
needs: test
40+
needs: [test]
4141
uses: ./.github/workflows/build.yml
4242
with:
4343
base: nvidia/cuda:12.8.1-cudnn-devel-ubuntu24.04
@@ -46,4 +46,25 @@ jobs:
4646
contents: read
4747
packages: write
4848
attestations: write
49-
id-token: write
49+
id-token: write
50+
51+
update-huggingface-dataset:
52+
needs: [test, build-cpu, build-cuda]
53+
if: github.ref == 'refs/heads/main'
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
- name: Install uv
59+
uses: astral-sh/setup-uv@v5
60+
- name: Install the project
61+
run: uv sync --all-extras --dev
62+
- name: Login to HuggingFace
63+
run: |
64+
uv run --with huggingface_hub huggingface-cli login --token $HF_TOKEN
65+
env:
66+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
67+
- name: Update HuggingFace dataset
68+
run: uv run scripts/update_huggingface_dataset.py
69+
env:
70+
HF_COMMIT_MESSAGE: Update dataset from CI on branch ${{ github.ref }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Script to update the HuggingFace dataset. Runs on on CI."""
2+
3+
import os
4+
5+
from datasets import Dataset
6+
from toolarena.definition import ToolDefinition
7+
from toolarena.utils import TASKS_DIR
8+
9+
HF_REPO_ID = os.getenv("HF_REPO_ID", "KatherLab/ToolArena")
10+
HF_COMMIT_MESSAGE = os.getenv("HF_COMMIT_MESSAGE", "Update dataset")
11+
12+
if __name__ == "__main__":
13+
ds = Dataset.from_list(
14+
[
15+
ToolDefinition.from_yaml(f).model_dump(mode="json")
16+
for f in TASKS_DIR.glob("*/task.yaml")
17+
]
18+
)
19+
ds.push_to_hub(HF_REPO_ID, commit_message=HF_COMMIT_MESSAGE)

0 commit comments

Comments
 (0)