From 7d08b405f461426d84e07bd09d5647e31179e0d4 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Thu, 20 Jul 2023 12:22:46 +0200 Subject: [PATCH 1/3] write down the version values in the operator cards --- pyproject.toml | 4 ++-- src/pineko/__init__.py | 1 + src/pineko/evolve.py | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 46aaf259..9eb1a07a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"] +build-backend = "poetry_dynamic_versioning.backend" [tool.poetry] name = "pineko" diff --git a/src/pineko/__init__.py b/src/pineko/__init__.py index 4b2068e6..884fc4b9 100644 --- a/src/pineko/__init__.py +++ b/src/pineko/__init__.py @@ -1,2 +1,3 @@ """pineko = PineAPPL + EKO.""" from .cli import command +from .version import __version__ diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index 978b2702..7a181470 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -2,6 +2,7 @@ import copy import os import pathlib +from importlib import metadata import eko import eko.basis_rotation as br @@ -133,6 +134,11 @@ def write_operator_card(pineappl_grid, default_card, card_path, tcard): operators_card["configs"]["interpolation_polynomial_degree"] = 1 operators_card["xgrid"] = x_grid.tolist() + # Add the version of eko and pineko to the operator card + # using importlib.metadata.version to get the correct tag in editable mode + operators_card["eko_version"] = metadata.version("eko") + operators_card["pineko_version"] = metadata.version("pineko") + with open(card_path, "w", encoding="UTF-8") as f: yaml.safe_dump(operators_card, f) return operators_card["xgrid"], q2_grid From 182a72d98de3aacb24db3a0b110d1f448edb56e1 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Thu, 20 Jul 2023 13:31:26 +0200 Subject: [PATCH 2/3] drop the pineko_version from the opcards that go into eko --- src/pineko/theory.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pineko/theory.py b/src/pineko/theory.py index acfb9f5b..0ec595c3 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -263,6 +263,9 @@ def load_operator_card(self, name): opcard_path = self.operator_cards_path / f"{name}.yaml" with open(opcard_path, encoding="utf-8") as f: ocard = yaml.safe_load(f) + # Drop the pineko_version if it is included as this is metadata for pineko only + if "pineko_version" in ocard: + ocard.pop("pineko_version") return ocard def activate_logging(self, path, filename, activated_loggers=()): From 11501be9ffa00e3ab182f8bdcd71072e503919e1 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 21 Jul 2023 12:09:30 +0200 Subject: [PATCH 3/3] add the pineko version as a comment --- src/pineko/evolve.py | 4 +++- src/pineko/theory.py | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pineko/evolve.py b/src/pineko/evolve.py index 9f6e90e3..86adac06 100644 --- a/src/pineko/evolve.py +++ b/src/pineko/evolve.py @@ -140,7 +140,7 @@ def write_operator_card(pineappl_grid, default_card, card_path, tcard): # Add the version of eko and pineko to the operator card # using importlib.metadata.version to get the correct tag in editable mode operators_card["eko_version"] = metadata.version("eko") - operators_card["pineko_version"] = metadata.version("pineko") + pineko_version = metadata.version("pineko") # Some safety checks if ( @@ -153,6 +153,8 @@ def write_operator_card(pineappl_grid, default_card, card_path, tcard): with open(card_path, "w", encoding="UTF-8") as f: yaml.safe_dump(operators_card, f) + f.write(f"# {pineko_version=}") + return operators_card["xgrid"], q2_grid diff --git a/src/pineko/theory.py b/src/pineko/theory.py index 0ec595c3..acfb9f5b 100644 --- a/src/pineko/theory.py +++ b/src/pineko/theory.py @@ -263,9 +263,6 @@ def load_operator_card(self, name): opcard_path = self.operator_cards_path / f"{name}.yaml" with open(opcard_path, encoding="utf-8") as f: ocard = yaml.safe_load(f) - # Drop the pineko_version if it is included as this is metadata for pineko only - if "pineko_version" in ocard: - ocard.pop("pineko_version") return ocard def activate_logging(self, path, filename, activated_loggers=()):