Skip to content

Commit

Permalink
Remove mentions of github pages (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherSpelt authored Oct 21, 2024
2 parents 9d515be + f512af9 commit d7b84bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
25 changes: 5 additions & 20 deletions task_registry/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import logging
import os
from pathlib import Path
Expand Down Expand Up @@ -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": [],
}
Expand All @@ -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
6 changes: 3 additions & 3 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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

0 comments on commit d7b84bb

Please sign in to comment.