From 23fc1c3b2b468adf8dba74ebd84fc86ed7483c34 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Mon, 30 Sep 2024 12:58:57 +0200 Subject: [PATCH] Fix CHANGELOG feature of aggregator related to #97 and #117 --- src/openeo_aggregator/about.py | 2 +- src/openeo_aggregator/backend.py | 33 ++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/openeo_aggregator/about.py b/src/openeo_aggregator/about.py index 8c7d26a..405cfd8 100644 --- a/src/openeo_aggregator/about.py +++ b/src/openeo_aggregator/about.py @@ -2,7 +2,7 @@ import sys from typing import Optional -__version__ = "0.39.1a1" +__version__ = "0.39.2a1" def log_version_info(logger: Optional[logging.Logger] = None): diff --git a/src/openeo_aggregator/backend.py b/src/openeo_aggregator/backend.py index 4a17da3..1148637 100644 --- a/src/openeo_aggregator/backend.py +++ b/src/openeo_aggregator/backend.py @@ -4,6 +4,8 @@ import dataclasses import datetime import functools +import importlib +import importlib.metadata import logging import pathlib import re @@ -27,6 +29,7 @@ import openeo import openeo.rest import openeo_driver.errors +import openeo_driver.util.changelog import openeo_driver.util.view_helpers from openeo.capabilities import ComparableVersion from openeo.rest import ( @@ -1601,9 +1604,27 @@ def postprocess_capabilities(self, capabilities: dict) -> dict: capabilities["_partitioned_job_tracking"] = bool(self.batch_jobs.partitioned_job_tracker) return capabilities - def changelog(self) -> Union[str, pathlib.Path]: - # TODO: What is path of CHANGELOG.md in docker container? It's probably not even there yet #97 - changelog = pathlib.Path(__file__).parent.parent.parent / "CHANGELOG.md" - if changelog.exists(): - return changelog - return super().changelog() + def changelog(self) -> Union[str, pathlib.Path, flask.Response]: + html = openeo_driver.util.changelog.multi_project_changelog( + [ + { + "name": "openeo-aggregator", + "version": importlib.metadata.version(distribution_name="openeo-aggregator"), + "changelog_path": openeo_driver.util.changelog.get_changelog_path( + data_files_dir="openeo-aggregator-data", + src_root=pathlib.Path(openeo_aggregator.__file__).parent.parent.parent, + filename="CHANGELOG.md", + ), + }, + { + "name": "openeo-python-driver", + "version": importlib.metadata.version(distribution_name="openeo_driver"), + "changelog_path": openeo_driver.util.changelog.get_changelog_path( + data_files_dir="openeo-python-driver-data", + src_root=pathlib.Path(openeo_driver.__file__).parent.parent, + filename="CHANGELOG.md", + ), + }, + ] + ) + return flask.make_response(html, {"Content-Type": "text/html"})