Skip to content

Commit c232f36

Browse files
committed
Revert "CLN remove template scripts"
This reverts commit 471132d.
1 parent 471132d commit c232f36

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

README.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
Template for Benchopt Benchmark repositories
2+
=============================================
3+
|Build Template|
4+
5+
This repo should be used with the following steps:
6+
7+
1. Hit the `Use this template` button on the top of `this page <https://github.com/benchopt/template_benchmark>`_,
8+
2. Use the form to create a new GitHub repository with your benchmark name,
9+
3. Clone the newly created repository on your computer,
10+
4. Run ``python clean_template.py`` script that will remove instructions relative to
11+
the template in ``README.rst`` and update it with your repo and org name.
12+
5. Edit the problem description in the ``README.rst``.
13+
6. Update ``objective.py`` and the files in ``datasets`` and ``solvers`` to create the benchmark.
114

215
My Benchopt Benchmark
316
=====================
@@ -15,14 +28,21 @@ This benchmark can be run using the following commands:
1528
.. code-block::
1629
1730
$ pip install -U benchopt
31+
$ git clone https://github.com/#ORG/#BENCHMARK_NAME
32+
$ benchopt run #BENCHMARK_NAME
1833
1934
Apart from the problem, options can be passed to ``benchopt run``, to restrict the benchmarks to some solvers or datasets, e.g.:
2035

2136
.. code-block::
2237
38+
$ benchopt run #BENCHMARK_NAME -s solver1 -d dataset2 --max-runs 10 --n-repetitions 10
2339
2440
2541
Use ``benchopt run -h`` for more details about these options, or visit https://benchopt.github.io/api.html.
2642

43+
.. |Build Template| image:: https://github.com/benchopt/template_benchmark_ml/workflows/Tests/badge.svg
44+
:target: https://github.com/benchopt/template_benchmark_ml/actions
45+
.. |Build Status| image:: https://github.com/#ORG/#BENCHMARK_NAME/workflows/Tests/badge.svg
46+
:target: https://github.com/#ORG/#BENCHMARK_NAME/actions
2747
.. |Python 3.6+| image:: https://img.shields.io/badge/python-3.6%2B-blue
2848
:target: https://www.python.org/downloads/release/python-360/

clean_template.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import re
2+
from pathlib import Path
3+
from subprocess import check_output
4+
5+
6+
if __name__ == "__main__":
7+
8+
# Get the name of the repo and parse org and bench name
9+
repo_url = check_output(['git', 'remote', 'get-url', 'origin']).decode()
10+
name = re.split('github.com[:/]', repo_url)[1].strip()
11+
ORG, BENCHMARK_NAME = name.replace('.git', '').split('/')
12+
13+
# update readme to have the right badge
14+
README = Path('README.rst')
15+
text = README.read_text()
16+
17+
text = text.replace('#ORG', ORG)
18+
text = text.replace('#BENCHMARK_NAME', BENCHMARK_NAME)
19+
20+
text = '\n'.join([line for line in text.splitlines()[13:]
21+
if 'template_benchmark' not in line] + [''])
22+
README.write_text(text)
23+
24+
# update the repo URL in the objective.py file
25+
file = Path("objective.py")
26+
text = file.read_text()
27+
text = text.replace('#ORG', ORG)
28+
text = text.replace('#BENCHMARK_NAME', BENCHMARK_NAME)
29+
file.write_text(text)
30+
31+
# Remove files specific to the template repo
32+
to_remove = [
33+
Path(".github") / "workflows" / "test_benchmarks.yml",
34+
Path(".github") / "workflows" / "lint_benchmarks.yml",
35+
Path(".") / "clean_template.py"
36+
]
37+
for file in to_remove:
38+
if file.exists():
39+
file.unlink()

objective.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Objective(BaseObjective):
1212
name = "Template benchmark"
1313

1414
# URL of the main repo for this benchmark.
15-
url = "https://github.com/benchopt/#BENCHMARK"
15+
url = "https://github.com/#ORG/#BENCHMARK"
1616

1717
# List of parameters for the objective. The benchmark will consider
1818
# the cross product for each key in the dictionary.

0 commit comments

Comments
 (0)