Skip to content

Commit 1339b68

Browse files
authored
Add version flag to wkcuber (#471)
* add version flag to wkcuber * update changelogs * create version file after publishing
1 parent 7ecf4e7 commit 1339b68

File tree

9 files changed

+93
-6
lines changed

9 files changed

+93
-6
lines changed

publish.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ for PKG in */pyproject.toml; do
2020
sed -i 's/\(.*\) = .* path \= \"\.\..*/\1 = "'"$PKG_VERSION"'"/g' pyproject.toml
2121
poetry publish --build -u "$PYPI_USERNAME" -p "$PYPI_PASSWORD"
2222

23+
echo "__version__ = '$PKG_VERSION'" > ./"$PKG"/version.py
24+
2325
# Restore files
2426
mv pyproject.toml.bak pyproject.toml
2527

webknossos/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,5 @@ ENV/
104104

105105
# MyPy
106106
.mypy_cache/
107+
108+
/webknossos/version.py

webknossos/Changelog.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/) `MAJOR.MINOR.PATCH`.
77
For upgrade instructions, please check the respective *Breaking Changes* sections.
88

9-
109
## Unreleased
1110
[Commits](https://github.com/scalableminds/webknossos-cuber/compare/v0.8.22...HEAD)
1211

13-
1412
### Breaking Changes
1513
### Added
1614
### Changed
@@ -23,6 +21,11 @@ For upgrade instructions, please check the respective *Breaking Changes* section
2321
### Breaking Changes
2422
- Removed the `organization` parameter from the `webknossos_context` function. The organization will automatically be fetched using the token of the user. [#470](https://github.com/scalableminds/webknossos-libs/pull/470)
2523

24+
### Fixed
25+
- Make Views picklable. We now ignore the file handle when we pickle Views. [#469](https://github.com/scalableminds/webknossos-libs/pull/469)
26+
27+
## [v0.8.19](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.19) - 2021-10-21
28+
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.8.18...v.8.19)
2629
### Added
2730
- Added a `User` class to the client that can be used to get meta-information of users or their logged time. The currently logged in user can be accessed, as well as all managed users. [#470](https://github.com/scalableminds/webknossos-libs/pull/470)
2831

wkcuber/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ testdata/tiff_mag_2_reference
108108
.mypy_cache/
109109

110110
/poetry.toml
111+
112+
/wkcuber/version.py

wkcuber/Changelog.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/) `MAJOR.MIN
77
For upgrade instructions, please check the respective *Breaking Changes* sections.
88

99
## Unreleased
10-
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.8.19...HEAD)
10+
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.8.20...HEAD)
1111

1212
### Breaking Changes in Config & CLI
1313
### Added
14+
- Added the flag `--version` to `wkcuber`. [#471](https://github.com/scalableminds/webknossos-libs/pull/471)
1415
### Changed
1516
### Fixed
1617

17-
## [0.8.19](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.19) - 2021-10-21
18-
[Commits](https://github.com/scalableminds/webknossos-cuber/compare/v0.8.18...v0.8.19)
18+
## [v0.8.20](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.20) - 2021-10-28
19+
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.8.19...v.8.20)
20+
21+
## [v0.8.19](https://github.com/scalableminds/webknossos-cuber/releases/tag/v0.8.19) - 2021-10-21
22+
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v0.8.18...v.8.19)
1923

2024
### Fixed
2125
- Fixed two bugs in `cubing` (regarding `start_z` and `pad`). As a result, the ImageConverters do no longer cache metadata. [#460](https://github.com/scalableminds/webknossos-libs/pull/460)

wkcuber/poetry.lock

Lines changed: 44 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wkcuber/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ czifile = "^2019.7.2"
2424
attrs = "^21.1.0"
2525
cattrs = "1.7.1"
2626
webknossos = { path = "../webknossos/", develop = true }
27+
GitPython = "^3.0.5"
2728

2829
[tool.poetry.dev-dependencies]
2930
black = "^20.8b1"

wkcuber/versioning.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def get_git_version() -> str:
2+
import git
3+
4+
git_hash = git.Repo(search_parent_directories=True).head.object.hexsha
5+
return git_hash
6+
7+
8+
def get_package_version() -> str:
9+
# pylint: disable=no-name-in-module,import-error
10+
from wkcuber.version import __version__
11+
12+
return __version__
13+
14+
15+
def get_available_version() -> str:
16+
"""
17+
If the current code lies in the published package, a version.py file will exist which was created at
18+
publish-time. That version info is returned here.
19+
Otherwise, the version is derived using the git repository in which the code lives.
20+
"""
21+
22+
try:
23+
return get_package_version()
24+
except ModuleNotFoundError:
25+
return get_git_version()

wkcuber/wkcuber/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List, Dict
22

3+
from versioning import get_available_version
34
from wkcuber import downsample_mags
45
from .compress import compress_mag_inplace
56
from .metadata import refresh_metadata
@@ -58,6 +59,10 @@ def create_parser() -> ArgumentParser:
5859
action="store_true",
5960
)
6061

62+
parser.add_argument(
63+
"--version", action="version", version=f"wkcuber {get_available_version()}"
64+
)
65+
6166
parser.add_argument("--name", "-n", help="Name of the dataset", default=None)
6267
add_isotropic_flag(parser)
6368
add_sampling_mode_flag(parser)

0 commit comments

Comments
 (0)