Skip to content

Dynamic versioning for postrelease versions #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Items without prefix refer to a global change.
## [Unreleased](https://github.com/NNPDF/eko/compare/v0.15.1...HEAD)

### Changed
- data: Changed version naming for unreleased eko versions from `0.0.0` to `0.0.0-sha` ([#448](https://github.com/NNPDF/eko/pull/448))
- data: Change version naming for unreleased eko versions from `0.0.0` to `0.0.0-post.{distance}+{commit hash}` ([#448](https://github.com/NNPDF/eko/pull/448)) ([#465](https://github.com/NNPDF/eko/pull/465))

### Fixed
- py: Remove usage of `ev_op_iterations` from truncated evolution as this is an inconsistent choice ([#459](https://github.com/NNPDF/eko/pull/459))
Expand Down
2 changes: 1 addition & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We need to ensure backward compatibility and thus we need to make some changes.
5. Also implement these changes in the old `vX.py` scripts (at the moment these are `v1.py` and `v2.py`).

> **Note**: We call the unreleased eko version `v0.0`. EKO's created with unpublished versions (`0.0.0` versions) are not part of this backward compatibility system.
> They have version `0.0.0-{commit}`, and they cannot necessarily be read by newer eko versions.
> They have version `0.0.0-{commit}` or `0.0.0`, and they cannot necessarily be read by newer eko versions.

### Instructions on how to update the test assets:

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ classifiers = [
]
repository = "https://github.com/NNPDF/eko"
include = [
"src/eko/version.py",
"doc/source/img/Logo.png",
"src/ekobox/genpdf/templatePDF.info",
"src/ekobox/genpdf/Toy.info",
Expand Down Expand Up @@ -92,7 +93,7 @@ enable = true
vcs = "git"
style = "semver"
dirty = true
format_jinja = "{% if distance == 0 %}{{ base }}{% else %} 0.0.0.{{ commit }}{% endif %}"
format-jinja = "{% if distance == 0 %}{{ base }}{% else %}0.0.0-post.{{ distance }}+{{ commit }}{% endif %}"

[tool.poetry-dynamic-versioning.substitution]
files = ["src/eko/version.py"]
Expand Down
12 changes: 3 additions & 9 deletions src/eko/io/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,17 @@ def load(cls, path: os.PathLike):
elif version.major == 0 and version.minor == 14:
raw = v2.update_metadata(paths, raw)
elif (
version.major == 0
and version.minor == 0
and version.micro == 0
and version.is_postrelease
version.base_version == str(version) == '0.0.0'
):
raise NotImplementedError(
"Unsupported version; use an eko from a published eko version!"
)
else:
if (
version.major == 0
and version.minor == 0
and version.micro == 0
and version.is_postrelease
version.base_version == str(version) == '0.0.0'
):
raise NotImplementedError(
"Unsupported version; use an eko from a published eko version!"
"Unsupported version; use an eko from a published eko version!"
)

# now we are ready
Expand Down
20 changes: 20 additions & 0 deletions tests/eko/io/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
import pytest
import yaml
from packaging.version import parse

from eko import EKO, interpolation
from eko.io import struct
Expand Down Expand Up @@ -195,3 +196,22 @@ def test_load_opened(self, tmp_path: pathlib.Path, eko_factory: EKOFactory):
read_opened = EKO.read(tmp_path, extract=False)

assert read_closed.metadata == read_opened.metadata

def test_version(self, tmp_path: pathlib.Path, eko_factory: EKOFactory):
"""Test asserted version. Should either be supported version, or have a postrelease addition"""
eko = eko_factory.get()
eko.close()
eko_factory.cache = None
assert eko.access.path is not None
read_closed = EKO.read(eko.access.path, dest=tmp_path)

version = parse(read_closed.metadata.version)
assert (
version.major + version.minor + version.micro > 0
and not version.is_postrelease
) or (
version.major == 0
and version.minor == 0
and version.micro == 0
and version.is_postrelease
)
Loading