Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a time template in module documentation generation #256

Merged
merged 7 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/update_available_software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the side-step here via this environment variable, why not just "hardcode" {{ generated_time }} in the generated pages?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that others sites can use the script without being forced to take the same approach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, doesn't hurt I guess.

python scripts/available_software/available_software.py
./scripts/update_generated_time.sh mkdocs.yml
git status
# determine whether pull request should be opened:
Expand Down
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
ocaisa marked this conversation as resolved.
Show resolved Hide resolved
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
Loading