Skip to content

Commit

Permalink
Merge pull request #831 from fsschneider/version_bump
Browse files Browse the repository at this point in the history
(Automatic) version bump
  • Loading branch information
priyakasimbeg authored Feb 5, 2025
2 parents c1f182e + 8171a32 commit def1a43
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ jobs:
pip install .[pytorch_cpu]
- name: Run pytest tests
run: |
pytest -vx tests/version_test.py
pytest -vx tests/test_version.py
pytest -vx tests/test_num_params.py
pytest -vx tests/test_param_shapes.py
pytest -vx tests/test_param_types.py
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ wandb/
scoring/plots/

!scoring/test_data/experiment_dir/study_0/mnist_jax/trial_0/eval_measurements.csv
!scoring/test_data/experiment_dir/study_0/mnist_jax/trial_1/eval_measurements.csv
!scoring/test_data/experiment_dir/study_0/mnist_jax/trial_1/eval_measurements.csv

algorithmic_efficiency/_version.py
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [Style Testing](#style-testing)
- [Unit and Integration Tests](#unit-and-integration-tests)
- [Regression Tests](#regression-tests)
- [Versioning](#versioning)

## Contributing to MLCommons

Expand Down Expand Up @@ -276,3 +277,15 @@ To run a regression test:
2. Turn on the self-hosted runner.
3. Run the self-hosted runner application for the runner to accept jobs.
4. Open a pull request into mian to trigger the workflow.

### Versioning

The package version is automatically determined by the `setuptools_scm` package based on the last git tag.
It follows the structure `major.minor.patch` + `devN` where `N` is the number of commits since the last tag.
It automatically increments the patch version (i.e. it guesses the next version) if there are commits after the last tag.
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).
You can check what version `setuptools_scm` is creating by running `python -m setuptools_scm`.
To create a new version, create a new release (and tag) in the GitHub UI.
The package version is automatically updated to the new version.
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__)"`.
4 changes: 3 additions & 1 deletion algorithmic_efficiency/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Algorithmic Efficiency."""

__version__ = '0.1.0'
from ._version import version as __version__

__all__ = ["__version__"]
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ zip-safe = false
[tool.setuptools.packages]
find = {} # Scanning implicit namespaces is active by default

[tool.setuptools.dynamic]
version = { attr = "algorithmic_efficiency.__version__" }
[tool.setuptools_scm]
version_file = "algorithmic_efficiency/_version.py"

###############################################################################
# (Optional) Dependencies #
Expand Down Expand Up @@ -129,6 +129,8 @@ wandb = ["wandb==0.16.5"]
based_on_style = "yapf"
each_dict_entry_on_separate_line = false
split_all_top_level_comma_separated_values = true
[tool.yapfignore]
ignore_patterns = ["algorithmic_efficiency/_version.py"]

# isort configuration
[tool.isort]
Expand All @@ -137,7 +139,7 @@ profile = "google"
# pylint configuration
[tool.pylint.MASTER]
persistent = false
ignore = "get_references_web.py,get_references_web_single_group.py"
ignore = "get_references_web.py,get_references_web_single_group.py,_version.py"

[tool.pylint.REPORTS]
reports = false
Expand Down
6 changes: 5 additions & 1 deletion tests/version_test.py → tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ def test_version_attribute():
version = algorithmic_efficiency.__version__
assert isinstance(version, str)
version_elements = version.split(".")
assert all(el.isnumeric() for el in version_elements)
print(version_elements)
# Only check the first two elements, i.e. major, minor
# (patch is not checked as it is not required).
# The remaining elements contain commit hash and dirty status.
assert all(el.isnumeric() for el in version_elements[0:2])

0 comments on commit def1a43

Please sign in to comment.