From 5bd97cc1d332d51c26e81f2e8c922950fb7146b0 Mon Sep 17 00:00:00 2001 From: ChristopherSpelt Date: Mon, 21 Oct 2024 10:33:08 +0200 Subject: [PATCH 1/2] Remove mentions of github pages --- task_registry/data.py | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/task_registry/data.py b/task_registry/data.py index cf371ac..d5e0474 100644 --- a/task_registry/data.py +++ b/task_registry/data.py @@ -1,4 +1,3 @@ -import json import logging import os from pathlib import Path @@ -30,21 +29,17 @@ def create_urn_mappper(entries: list[dict[str, Any]]) -> dict[str, Any]: def generate_index( - base_url: str = "https://minbzk.github.io/task-registry", + base_url: str = "https://task-registry.apps.digilab.network", directory: str = "instruments", - output_file: str = "index.json", ) -> dict[str, Any]: - # TODO: For now the generation and saving of the index.json is coupled, because of backwards - # compatibility for AMT. In the future the download url and links will be the endpoint of - # our API, so the coupling can be removed. index: dict[str, Any] = { "type": "dir", "size": 0, "name": directory, "path": directory, - "download_url": f"{base_url}/{output_file}", + "download_url": f"{base_url}/instruments", "_links": { - "self": f"{base_url}/{output_file}", + "self": f"{base_url}/instruments", }, "entries": [], } @@ -62,21 +57,11 @@ def generate_index( "name": file, "path": relative_path, "urn": instrument["urn"], - "download_url": f"{base_url}/{relative_path}", + "download_url": f"{base_url}/urns/?urn={instrument['urn']}", "_links": { - "self": f"{base_url}/{relative_path}", + "self": f"{base_url}/urns/?urn={instrument['urn']}", }, } index["entries"].append(file_info) - with open(output_file, "w") as f: - json.dump(index, f, indent=4) - logger.info(f"Saved index file to {output_file}") - return index - - -# This will be removed when the deploy script in script/ is not necessary anymore. -# This wrapper is needed because the CI script fails when other than None is returned. -def main() -> None: - generate_index() # pragma: no cover From f512af980ad337108c84e2f52c48f8b64534f9ed Mon Sep 17 00:00:00 2001 From: ChristopherSpelt Date: Mon, 21 Oct 2024 10:38:33 +0200 Subject: [PATCH 2/2] Fix failing test --- tests/test_data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_data.py b/tests/test_data.py index ecf92b7..0bdee16 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -6,8 +6,8 @@ logger = logging.getLogger(__name__) TEST_INDEX: dict[str, Any] = { - "_links": {"self": "test.io/index.json"}, - "download_url": "test.io/index.json", + "_links": {"self": "ourapi.io/instruments"}, + "download_url": "ourapi.io/instruments", "entries": [], "name": "test", "path": "test", @@ -22,5 +22,5 @@ def test_create_urn_mappper() -> None: def test_generate_index() -> None: - index = data.generate_index(base_url="test.io", directory="test", output_file="index.json") + index = data.generate_index(base_url="ourapi.io", directory="test") assert index == TEST_INDEX