Skip to content

Commit

Permalink
Use a time template in module documentation generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ocaisa committed Aug 7, 2024
1 parent ea3148f commit a12ecac
Show file tree
Hide file tree
Showing 7 changed files with 57 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
@@ -1,5 +1,6 @@
name: Update overview of available software in EESSI
on:
pull_request:
workflow_dispatch:
schedule:
# run every 4 hours
Expand Down Expand Up @@ -34,6 +35,7 @@ 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
git status
Expand All @@ -47,6 +49,7 @@ jobs:
else
echo "JSON files in docs/available_software/data have been changed, PR should be opened"
echo "json_data_changed=yes" >> $GITHUB_OUTPUT
./scripts/update_generated_time.sh mkdocs.yml
fi
# remove original JSON files, or they'll end up in the PR being opened
Expand Down
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,14 @@ markdown_extensions:
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
# Enable macros so we can use global variables
- macros
extra:
# add links in bottom right
social:
- icon: fontawesome/brands/twitter
link: https://twitter.com/eessi_hpc
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
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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)


# --------------------------------------------------------------------------------------------------------
Expand Down
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:
Expand All @@ -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
Expand All @@ -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 a12ecac

Please sign in to comment.