Skip to content

Commit 1d298ab

Browse files
committed
Merge remote-tracking branch 'origin/main'
# Conflicts: # deepinv_bench/benchmarks/div2k_gaussian_deblurring/solvers/dps.py # deepinv_bench/benchmarks/div2k_inpainting_easy/solvers/dps.py # deepinv_bench/benchmarks/div2k_super_resolution_2x/solvers/dps.py
2 parents 74d6bc1 + f26f3c0 commit 1d298ab

6 files changed

Lines changed: 39 additions & 17 deletions

File tree

.github/scripts/find_benchmarks.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,20 @@ def main() -> None:
9494
root = Path.cwd()
9595
repo = Repo(root)
9696

97-
# Find all benchmark directories
97+
# Retrieve all benchmark directories and setup dispatch filters based
98+
# on dispatch context and git reference range (if applicable)
9899
all_dirs = find_benchmark_dirs(root)
99-
100-
# Get reference range for filtering
100+
dispatch_benchmark_dir = os.environ.get("DISPATCH_BENCHMARK_DIR", "")
101101
ref_range = get_ref_range(repo)
102102

103-
if ref_range and not args.all:
103+
if dispatch_benchmark_dir:
104+
# If a specific benchmark dir is provided via dispatch, directly include it.
105+
assert dispatch_benchmark_dir in all_dirs, (
106+
f"Provided BENCHMARK_DIR '{dispatch_benchmark_dir}' is not a valid benchmark.\n"
107+
"Valid values are:\n- " + "\n- ".join(all_dirs)
108+
)
109+
filtered_dirs = [dispatch_benchmark_dir]
110+
elif ref_range and not args.all:
104111
base, head = ref_range
105112
changed_files = get_changed_files(repo, base, head)
106113
filtered_dirs = filter_changed_dirs(all_dirs, changed_files)
@@ -109,14 +116,14 @@ def main() -> None:
109116
filtered_dirs = all_dirs
110117

111118
# Output as JSON
119+
print(f"Found benchmark directories:\n{filtered_dirs}")
112120
result = json.dumps(filtered_dirs)
113-
print(result)
114121

115122
# If running in GitHub Actions, set the output
116123
github_output = os.environ.get("GITHUB_OUTPUT")
117124
if github_output:
118125
with open(github_output, "a") as f:
119-
f.write(f"dirs={result}\n")
126+
f.write(f"dirs={result}\nfound_benchmarks={len(filtered_dirs) > 0}\n")
120127

121128

122129
if __name__ == "__main__":

.github/workflows/benchopt_test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- main
7-
create:
87
tags:
98
- '**'
109
pull_request:
@@ -17,14 +16,15 @@ jobs:
1716
runs-on: ubuntu-latest
1817
outputs:
1918
benchmark-dirs: ${{ steps.find-dirs.outputs.dirs }}
19+
found_benchmarks: ${{ steps.find-dirs.outputs.found_benchmarks }}
2020
steps:
2121
- uses: actions/checkout@v3
2222
with:
2323
fetch-depth: 0
2424
- name: Set up Python
2525
uses: actions/setup-python@v5
2626
with:
27-
python-version: '3.11'
27+
python-version: '3.14'
2828
- name: Install dependencies
2929
run: pip install GitPython
3030
- name: Find benchmark directories
@@ -38,6 +38,7 @@ jobs:
3838

3939
benchopt-tests:
4040
needs: find-benchmarks
41+
if : needs.find-benchmarks.outputs.found_benchmarks == 'True'
4142
strategy:
4243
matrix:
4344
benchmark_dir: ${{ fromJson(needs.find-benchmarks.outputs.benchmark-dirs) }}

.github/workflows/deepinv_run_hf.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@ on:
44
push:
55
branches:
66
- main
7-
create:
87
tags:
98
- '**'
109
workflow_dispatch:
10+
inputs:
11+
benchmark_dir:
12+
description: 'Single benchmark dir to run (leave empty to run all)'
13+
required: false
14+
default: ''
1115

1216
jobs:
1317
find-benchmarks:
1418
runs-on: ubuntu-latest
1519
outputs:
1620
benchmark-dirs: ${{ steps.find-dirs.outputs.dirs }}
21+
found_benchmarks: ${{ steps.find-dirs.outputs.found_benchmarks }}
1722
steps:
1823
- uses: actions/checkout@v3
1924
with:
2025
fetch-depth: 0
2126
- name: Set up Python
2227
uses: actions/setup-python@v5
2328
with:
24-
python-version: '3.11'
29+
python-version: '3.14'
2530
- name: Install dependencies
2631
run: pip install GitPython
2732
- name: Find benchmark directories
@@ -32,10 +37,12 @@ jobs:
3237
GITHUB_EVENT_NAME: ${{ github.event_name }}
3338
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
3439
GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }}
40+
DISPATCH_BENCHMARK_DIR: ${{ inputs.benchmark_dir }}
3541

3642
run-benchmarks:
3743
runs-on: gpu # ubuntu-latest
3844
needs: find-benchmarks
45+
if : needs.find-benchmarks.outputs.found_benchmarks == 'True'
3946
timeout-minutes: 4320 # 3 days (max)
4047
strategy:
4148
matrix:
@@ -67,19 +74,17 @@ jobs:
6774
run: |
6875
rm -rf $HOME || echo "HOME "$HOME" doesn't exist"
6976
mkdir -p $HOME
70-
- name: Get Date
77+
- name: Compute cache key based on the date (monthly)
7178
id: get-date
7279
run: |
7380
echo "date=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
7481
shell: bash
7582
- name: Cache benchopt runs and conda packages
7683
id: cache-benchopt
77-
uses: actions/cache@v5
84+
uses: actions/cache/restore@v5 # restore only
7885
with:
7986
path: |
8087
${{ matrix.benchmark_dir }}/__cache__
81-
# The cache is unique for each benchmark directory, OS and we
82-
# invalidate it every month to avoid stale caches.
8388
key: ${{ runner.os }}-${{matrix.benchmark_dir}}-${{ steps.get-date.outputs.date }}
8489

8590
- name: Setup Conda
@@ -110,8 +115,17 @@ jobs:
110115
--no-plot --env-name ${{ env.RUN_CONDA_ENV }}
111116
112117
- name: Upload results
118+
if: always()
113119
run: |
114120
benchopt publish ${{ matrix.benchmark_dir }} --hub huggingface \
115121
--filename ${{ matrix.benchmark_dir }}/outputs/results_ci_run.csv \
116122
--repo deepinv/benchmarks --keep last \
117123
--token ${{ secrets.HF_TOKEN }}
124+
125+
- name: Save cache
126+
if: always()
127+
uses: actions/cache/save@v5
128+
with:
129+
path: |
130+
${{ matrix.benchmark_dir }}/__cache__
131+
key: ${{ runner.os }}-${{matrix.benchmark_dir}}-${{ steps.get-date.outputs.date }}

deepinv_bench/benchmarks/div2k_gaussian_deblurring/solvers/dps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def set_objective(self, train_dataset=None, physics=None):
3030
raise NotImplementedError
3131

3232
self.model = dinv.sampling.DPS(
33-
model=denoiser, device=device, max_iter=self.max_iter, dtype=torch.float32
33+
denoiser=denoiser, device=device, max_iter=self.max_iter, dtype=torch.float32
3434
)
3535
self.model.device = device
3636

deepinv_bench/benchmarks/div2k_inpainting_easy/solvers/dps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def set_objective(self, train_dataset=None, physics=None):
3030
raise NotImplementedError
3131

3232
self.model = dinv.sampling.DPS(
33-
model=denoiser, device=device, max_iter=self.max_iter, dtype=torch.float32
33+
denoiser=denoiser, device=device, max_iter=self.max_iter, dtype=torch.float32
3434
)
3535
self.model.device = device
3636

deepinv_bench/benchmarks/div2k_super_resolution_2x/solvers/dps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def set_objective(self, train_dataset=None, physics=None):
3030
raise NotImplementedError
3131

3232
self.model = dinv.sampling.DPS(
33-
model=denoiser, device=device, max_iter=self.max_iter, dtype=torch.float32
33+
denoiser=denoiser, device=device, max_iter=self.max_iter, dtype=torch.float32
3434
)
3535
self.model.device = device
3636

0 commit comments

Comments
 (0)