Skip to content

Commit

Permalink
specify which repo to push to (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasMoutawwakil authored Apr 13, 2024
1 parent 8a7abf6 commit 950a9b9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/test_api_cpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ jobs:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -e .[testing,timm,diffusers]
- name: HF Hub login
- name: Run tests
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
PUSH_REPO_ID: optimum-benchmark/cpu
run: |
huggingface-cli login --token $HF_TOKEN
- name: Run tests
run: pytest -s -k "api and cpu"
pytest -s -k "api and cpu"
3 changes: 2 additions & 1 deletion .github/workflows/test_api_cuda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ jobs:
uses: addnab/docker-run-action@v3
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
PUSH_REPO_ID: optimum-benchmark/cuda
with:
image: pytorch/pytorch:2.2.2-cuda12.1-cudnn8-runtime
options: |
--rm
--gpus all
--shm-size 64G
--env HF_TOKEN
--env PUSH_REPO_ID
--env MKL_THREADING_LAYER=GNU
--volume ${{ github.workspace }}:/workspace
--workdir /workspace
run: |
pip install -e .[testing,timm,diffusers]
huggingface-cli login --token $HF_TOKEN
pytest -s -x -k "api and cuda"
9 changes: 4 additions & 5 deletions .github/workflows/test_api_misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ jobs:
- name: Install requirements
run: |
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -e .[testing,timm,diffusers]
- name: HF Hub login
- name: Run tests
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
PUSH_REPO_ID: optimum-benchmark/misc
run: |
huggingface-cli login --token $HF_TOKEN
- name: Run tests
run: pytest -s -k "api and not (cpu or cuda)"
pytest -s -k "api and not (cpu or cuda)"
5 changes: 3 additions & 2 deletions .github/workflows/test_api_rocm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ jobs:
env:
DEVICE: ${{ env.DEVICE }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
PUSH_REPO_ID: optimum-benchmark/rocm
with:
image: opt-bench-rocm:${{ matrix.image.rocm_version }}
options: |
--rm
--pid host
--shm-size 64G
--env HF_TOKEN
--device /dev/kfd
--env PUSH_REPO_ID
--device /dev/kfd/
--device /dev/dri/${{ env.DEVICE }}
--volume ${{ github.workspace }}:/workspace
--workdir /workspace
run: |
pip install -e .[testing,timm,diffusers]
hugingface-cli login --token $HF_TOKEN
pytest -s -x -k "api and cuda"
1 change: 1 addition & 0 deletions .github/workflows/test_cli_misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Install requirements
run: |
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -e .[testing]
- name: Run tests
Expand Down
17 changes: 8 additions & 9 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from optimum_benchmark.trackers.latency import LatencyTracker, Timer
from optimum_benchmark.trackers.memory import MemoryTracker

HF_ORGA_ID = "optimum-benchmark"
PUSH_REPO_ID = os.environ.get("PUSH_REPO_ID", "optimum-benchmark/misc")

LIBRARIES_TASKS_MODELS = [
("timm", "image-classification", "timm/resnet50.a1_in1k"),
("transformers", "text-generation", "openai-community/gpt2"),
Expand Down Expand Up @@ -87,13 +88,11 @@ def test_api_launch(device, benchmark, library, task, model):
)
benchmark_report = launch(experiment_config)

repo_id = f"{HF_ORGA_ID}/{device}"
experiment_config.push_to_hub(repo_id=repo_id, subfolder=experiment_name)
benchmark_report.push_to_hub(repo_id=repo_id, subfolder=experiment_name)
experiment_config.push_to_hub(repo_id=PUSH_REPO_ID, subfolder=experiment_name)
benchmark_report.push_to_hub(repo_id=PUSH_REPO_ID, subfolder=experiment_name)


def test_api_push_to_hub_mixin():
repo_id = f"{HF_ORGA_ID}/misc"
experiment_name = "test_api_push_to_hub_mixin"

launcher_config = ProcessConfig(device_isolation=False)
Expand Down Expand Up @@ -123,9 +122,9 @@ def test_api_push_to_hub_mixin():
pd.testing.assert_frame_equal(from_csv_experiment_config.to_dataframe(), experiment_config.to_dataframe())

# Hugging Face Hub API
experiment_config.push_to_hub(repo_id=repo_id, subfolder=experiment_name)
experiment_config.push_to_hub(repo_id=PUSH_REPO_ID, subfolder=experiment_name)
from_hub_experiment_config: ExperimentConfig = ExperimentConfig.from_pretrained(
repo_id=repo_id, subfolder=experiment_name
repo_id=PUSH_REPO_ID, subfolder=experiment_name
)
assert from_hub_experiment_config.to_dict() == experiment_config.to_dict()

Expand All @@ -143,9 +142,9 @@ def test_api_push_to_hub_mixin():
pd.testing.assert_frame_equal(from_csv_benchmark_report.to_dataframe(), benchmark_report.to_dataframe())

# Hugging Face Hub API
benchmark_report.push_to_hub(repo_id=repo_id, subfolder=experiment_name)
benchmark_report.push_to_hub(repo_id=PUSH_REPO_ID, subfolder=experiment_name)
from_hub_benchmark_report: BenchmarkReport = BenchmarkReport.from_pretrained(
repo_id=repo_id, subfolder=experiment_name
repo_id=PUSH_REPO_ID, subfolder=experiment_name
)
assert from_hub_benchmark_report.to_dict() == benchmark_report.to_dict()

Expand Down

0 comments on commit 950a9b9

Please sign in to comment.