Skip to content

Commit

Permalink
Add versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
klieret committed Jul 31, 2023
1 parent 230e3a7 commit efdfb0a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# GNNs for Charged Particle Tracking

[![CalVer YY.0M.MICRO](https://img.shields.io/badge/calver-YY.0M.MICRO-22bfda.svg)][calver]
[![Documentation Status](https://readthedocs.org/projects/gnn-tracking/badge/?version=latest)](https://gnn-tracking.readthedocs.io/en/latest/?badge=latest)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/gnn-tracking/gnn_tracking/main.svg)](https://results.pre-commit.ci/latest/github/gnn-tracking/gnn_tracking/main)
[![gh actions](https://github.com/gnn-tracking/gnn_tracking/actions/workflows/test.yaml/badge.svg)](https://github.com/gnn-tracking/gnn_tracking/actions)
Expand All @@ -28,10 +29,12 @@ See the [readme of the organization][organization-readme] for an overview of the
5. For development: Install [pre-commit][] hooks: `pre-commit install` (from this directory)

A good place to get started are the [demo notebooks][demo].
This package is versioned based on the [![CalVer YY.0M.MICRO](https://img.shields.io/badge/calver-YY.0M.MICRO-22bfda.svg) CalVer scheme][calver].

[mamba install]: https://mamba.readthedocs.io/en/latest/installation.html
[demo]: https://github.com/gnn-tracking/tutorials
[pre-commit]: https://pre-commit.com
[calver]: https://calver.org/

## 🧰 Development guidelines

Expand Down
5 changes: 5 additions & 0 deletions src/gnn_tracking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pathlib import Path

__all__ = ["__version__"]

__version__ = (Path(__file__).resolve().parent / "version.txt").read_text().strip()
9 changes: 9 additions & 0 deletions src/gnn_tracking/utils/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from types import ModuleType

import git
from packaging import version

import gnn_tracking
from gnn_tracking.utils.log import logger


Expand All @@ -28,3 +30,10 @@ def get_commit_hash(module: None | ModuleType | str | PathLike = None) -> str:
"Repository %s is dirty, commit hash may not be accurate.", base_path
)
return repo.head.object.hexsha


def assert_version_geq(require: str):
assert version.parse(gnn_tracking.__version__) >= version.parse(require), (
f"Please update gnn_tracking from {gnn_tracking.__version__} to at least "
f"version {require}."
)
2 changes: 1 addition & 1 deletion src/gnn_tracking/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
23.07.00
6 changes: 6 additions & 0 deletions tests/test_versioning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import gnn_tracking
from gnn_tracking.utils.versioning import assert_version_geq


def test_versioning_geq():
assert_version_geq(gnn_tracking.__version__)

0 comments on commit efdfb0a

Please sign in to comment.