Skip to content

Commit def1a43

Browse files
Merge pull request #831 from fsschneider/version_bump
(Automatic) version bump
2 parents c1f182e + 8171a32 commit def1a43

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ jobs:
199199
pip install .[pytorch_cpu]
200200
- name: Run pytest tests
201201
run: |
202-
pytest -vx tests/version_test.py
202+
pytest -vx tests/test_version.py
203203
pytest -vx tests/test_num_params.py
204204
pytest -vx tests/test_param_shapes.py
205205
pytest -vx tests/test_param_types.py

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ wandb/
2323
scoring/plots/
2424

2525
!scoring/test_data/experiment_dir/study_0/mnist_jax/trial_0/eval_measurements.csv
26-
!scoring/test_data/experiment_dir/study_0/mnist_jax/trial_1/eval_measurements.csv
26+
!scoring/test_data/experiment_dir/study_0/mnist_jax/trial_1/eval_measurements.csv
27+
28+
algorithmic_efficiency/_version.py

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Style Testing](#style-testing)
2323
- [Unit and Integration Tests](#unit-and-integration-tests)
2424
- [Regression Tests](#regression-tests)
25+
- [Versioning](#versioning)
2526

2627
## Contributing to MLCommons
2728

@@ -276,3 +277,15 @@ To run a regression test:
276277
2. Turn on the self-hosted runner.
277278
3. Run the self-hosted runner application for the runner to accept jobs.
278279
4. Open a pull request into mian to trigger the workflow.
280+
281+
### Versioning
282+
283+
The package version is automatically determined by the `setuptools_scm` package based on the last git tag.
284+
It follows the structure `major.minor.patch` + `devN` where `N` is the number of commits since the last tag.
285+
It automatically increments the patch version (i.e. it guesses the next version) if there are commits after the last tag.
286+
Additionally, if there are uncommitted changes, the version will include a suffix separated by a `+` character and includes the last commit hash plus the date on dirt workdir (see [setuptools_scm's documentation](https://setuptools-scm.readthedocs.io/en/latest/extending/#setuptools_scmlocal_scheme) with the default version and local scheme).
287+
You can check what version `setuptools_scm` is creating by running `python -m setuptools_scm`.
288+
289+
To create a new version, create a new release (and tag) in the GitHub UI.
290+
The package version is automatically updated to the new version.
291+
Once the package is installed, the version can be accessed as the package attribute `algorithmic_efficiency.__version__`, i.e. via `python -c "import algorithmic_efficiency; print(algorithmic_efficiency.__version__)"`.

algorithmic_efficiency/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
"""Algorithmic Efficiency."""
22

3-
__version__ = '0.1.0'
3+
from ._version import version as __version__
4+
5+
__all__ = ["__version__"]

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ zip-safe = false
6161
[tool.setuptools.packages]
6262
find = {} # Scanning implicit namespaces is active by default
6363

64-
[tool.setuptools.dynamic]
65-
version = { attr = "algorithmic_efficiency.__version__" }
64+
[tool.setuptools_scm]
65+
version_file = "algorithmic_efficiency/_version.py"
6666

6767
###############################################################################
6868
# (Optional) Dependencies #
@@ -129,6 +129,8 @@ wandb = ["wandb==0.16.5"]
129129
based_on_style = "yapf"
130130
each_dict_entry_on_separate_line = false
131131
split_all_top_level_comma_separated_values = true
132+
[tool.yapfignore]
133+
ignore_patterns = ["algorithmic_efficiency/_version.py"]
132134

133135
# isort configuration
134136
[tool.isort]
@@ -137,7 +139,7 @@ profile = "google"
137139
# pylint configuration
138140
[tool.pylint.MASTER]
139141
persistent = false
140-
ignore = "get_references_web.py,get_references_web_single_group.py"
142+
ignore = "get_references_web.py,get_references_web_single_group.py,_version.py"
141143

142144
[tool.pylint.REPORTS]
143145
reports = false

tests/version_test.py renamed to tests/test_version.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ def test_version_attribute():
1010
version = algorithmic_efficiency.__version__
1111
assert isinstance(version, str)
1212
version_elements = version.split(".")
13-
assert all(el.isnumeric() for el in version_elements)
13+
print(version_elements)
14+
# Only check the first two elements, i.e. major, minor
15+
# (patch is not checked as it is not required).
16+
# The remaining elements contain commit hash and dirty status.
17+
assert all(el.isnumeric() for el in version_elements[0:2])

0 commit comments

Comments
 (0)