Skip to content

Commit

Permalink
Merge pull request #256 from ocaisa/reduce_module_update_impact
Browse files Browse the repository at this point in the history
Use a time template in module documentation generation
boegel authored Aug 8, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 7479110 + 4583294 commit 61ef7d2
Showing 7 changed files with 58 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/update_available_software.yml
Original file line number Diff line number Diff line change
@@ -34,7 +34,10 @@ jobs:
cp docs/available_software/data/json_data.json docs/available_software/data/json_data.json.orig
cp docs/available_software/data/json_data_detail.json docs/available_software/data/json_data_detail.json.orig
export TIME_GENERATED_TEMPLATE="{{ generated_time }}"
python scripts/available_software/available_software.py
./scripts/update_generated_time.sh mkdocs.yml
git status
# determine whether pull request should be opened:
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -79,6 +79,8 @@ plugins:
- git-revision-date-localized
# necessary for search to work
- search
# Enable macros so we can use global variables
- macros
- redirects:
redirect_maps:
adding_software.md: adding_software/overview.md
@@ -123,6 +125,8 @@ extra:
social:
- icon: fontawesome/brands/twitter
link: https://twitter.com/eessi_hpc
# this gets auto-updated via update_generated_time.sh script run in update_available_software.yml action
generated_time: "Wed, 07 Aug 2024 at 17:08:54 CEST"
extra_javascript:
# mermaid diagram
- https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ mkdocs-material
mkdocs-redirects
mkdocs-git-revision-date-localized-plugin
mkdocs-toc-sidebar-plugin
mkdocs-macros-plugin
8 changes: 7 additions & 1 deletion scripts/available_software/available_software.py
Original file line number Diff line number Diff line change
@@ -408,8 +408,14 @@ def generate_detail_pages(json_path, dest_path) -> None:
data = json.load(json_data)

all_targets = data["targets"]

time_generated_template = os.environ.get('TIME_GENERATED_TEMPLATE')
for software, content in data["software"].items():
generate_software_detail_page(software, content, data["time_generated"], all_targets, dest_path)
if time_generated_template:
time_generated = time_generated_template
else:
time_generated = data["time_generated"]
generate_software_detail_page(software, content, time_generated, all_targets, dest_path)


# --------------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
hide:
- toc
---

science
=======

# Available modules


The overview below shows which science installations are available per target architecture in EESSI, ordered based on software version (new to old).

To start using science, load one of these modules using a `module load` command like:

```shell
module load science/7.2.0
```

*(This data was automatically generated on {{ generated_date }})*

| |aarch64/generic|x86_64/amd/zen2|
| :---: | :---: | :---: |
|science/7.2.0|x|x|
|science/5.3.0|x|x|
12 changes: 12 additions & 0 deletions scripts/available_software/tests/test_md.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from mdutils.mdutils import MdUtils
from available_software import get_unique_software_names, modules_eessi, generate_table_data, generate_module_table
from available_software import generate_detail_pages
import os
import filecmp
import shutil


class TestMarkdown:
@@ -22,6 +24,8 @@ def setup_class(cls):
def teardown_class(cls):
if os.path.exists("test_simple.md"):
os.remove("test_simple.md")
if os.path.exists("detailed_md"):
shutil.rmtree("detailed_md")

# ---------------------------
# Markdown tests
@@ -41,3 +45,11 @@ def test_md_simple(self):
md_file.create_md_file()
assert os.path.exists("test_simple.md")
assert filecmp.cmp(self.path + "/data/test_md_simple_sol.md", "test_simple.md")

def test_md_detailed_template(self):
os.environ["TIME_GENERATED_TEMPLATE"] = "{{ generated_date }}"
os.mkdir('detailed_md')
generate_detail_pages(self.path + "/data/test_json_simple_sol_detail.json", 'detailed_md')
del os.environ["TIME_GENERATED_TEMPLATE"]
assert os.path.exists("detailed_md/science.md")
assert filecmp.cmp(self.path + "/data/test_md_template_detailed_science_sol.md", "detailed_md/science.md")
6 changes: 6 additions & 0 deletions scripts/update_generated_time.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Get the new date
NEW_DATE="$(date '+%a, %d %b %Y at %H:%M:%S %Z')"
# Inject it into the target file
sed -i 's/\(generated_time: "\)[^"]*\(".*\)/\1'"${NEW_DATE}"'\2/' $1

0 comments on commit 61ef7d2

Please sign in to comment.