From bba47ff59e70a97f59b53e89861f26b871f87efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20He=C4=8Dko?= Date: Wed, 2 Sep 2026 14:36:10 +0200 Subject: [PATCH 1/5] Fix fetch_b2input_xml_files.py to work with the github repo of SOLPS --- extras/b2input/fetch_b2input_xml_files.py | 77 ++++++----------------- 1 file changed, 18 insertions(+), 59 deletions(-) diff --git a/extras/b2input/fetch_b2input_xml_files.py b/extras/b2input/fetch_b2input_xml_files.py index 7ceef7c..51fd34d 100644 --- a/extras/b2input/fetch_b2input_xml_files.py +++ b/extras/b2input/fetch_b2input_xml_files.py @@ -1,20 +1,16 @@ """ Fetch b2input.xml files (and xhtml-symbol.ent) from different versions -of the B2.5 repository hosted on https://git.iter.org. +of the B2.5 repository hosted on https://github.com/iterorganization/. Usage: - export GIT_ITER_USER="username" - export GIT_ITER_TOKEN="some_secret_token" python fetch_b2input_xml_files.py ./versions.yaml -d ./fetched """ import argparse import logging -import os import shutil -import subprocess -import tempfile +import urllib.request from pathlib import Path import yaml @@ -22,40 +18,21 @@ logger = logging.getLogger() -def fetch_b25_repo_file(git_user, git_token, ref, src, dest): +def fetch_b25_repo_file(ref, src, dest): """Fetch B2.5 repository and copy a file from it.""" if not shutil.which('git'): raise RuntimeError('Command `git` not found, please install git') - repourl = f'https://{git_user}:{git_token}@git.iter.org/scm/bnd/b2.5.git' - - # Remove the prefix if ref is specified using the full git ref name - if ref.startswith('refs/'): - for prefix in ('refs/heads/', 'refs/tags/'): - if ref.startswith(prefix): - ref = ref.removeprefix(prefix) - break - else: - raise RuntimeError(f'Unsupported ref "{ref}", expected "refs/heads/..." or "refs/tags/..."') - - with tempfile.TemporaryDirectory(prefix='b2.5_') as tmpdir: - repodir = Path(tmpdir, ref.replace('/', '_')) - result = subprocess.run( - ['git', 'clone', '--depth', '1', '--branch', ref, repourl, str(repodir)], - # stdout=subprocess.DEVNULL, - # stderr=subprocess.DEVNULL, - ) - if result.returncode != 0: - raise RuntimeError( - f'Failed to clone the B2.5 repository at ref "{ref}", return code={result.returncode},' - + ' possibly a token authentication issue or invalid branch/tag name' - ) - if not (repodir / src).exists(): - raise RuntimeError(f'File "{src}" not found in the B2.5 repository at ref "{ref}"') - with open(dest, 'wb') as f: - f.write((repodir / src).read_bytes()) - - -def fetch_all_versions(git_user, git_token, versions_yaml, dest_dir): + if not any(ref.startswith(prefix) for prefix in ('refs/heads/', 'refs/tags/')): + raise RuntimeError(f'Unsupported ref "{ref}", expected "refs/heads/..." or "refs/tags/..."') + + fileurl = f'https://github.com/iterorganization/B2.5/raw/{ref}/{src}' + try: + urllib.request.urlretrieve(fileurl, dest) + except urllib.error.HTTPError as e: + raise RuntimeError(f'Failed to fetch file from {fileurl}: {e}') from e + + +def fetch_all_versions(versions_yaml, dest_dir): if not Path(dest_dir).exists(): Path(dest_dir).mkdir(exist_ok=True, parents=True) @@ -66,7 +43,7 @@ def fetch_all_versions(git_user, git_token, versions_yaml, dest_dir): git_ref = config['xhtml_symbol']['git_ref'] path = Path(dest_dir, 'xhtml-symbol.ent') logger.info(f'Downloading xhtml-symbol.ent at ref "{git_ref}" to "{path}"') - fetch_b25_repo_file(git_user, git_token, git_ref, 'src/documentation/xhtml-symbol.ent', path) + fetch_b25_repo_file(git_ref, 'src/documentation/xhtml-symbol.ent', path) for item in config['versions']: git_ref = item['git_ref'] @@ -74,23 +51,19 @@ def fetch_all_versions(git_user, git_token, versions_yaml, dest_dir): logger.info(f'Downloading b2input.xml at ref "{git_ref}" to "{path}"') if ' ' in item['label']: raise ValueError(f'Version label "{item["label"]}" contains a space') - fetch_b25_repo_file(git_user, git_token, git_ref, 'src/documentation/b2input.xml', path) + fetch_b25_repo_file(git_ref, 'src/documentation/b2input.xml', path) parser = argparse.ArgumentParser() parser.add_argument('versions_yaml', metavar='PATH_VERSIONS_YAML', help=( - 'path to a "versions.yaml" file containing the list of git refs in the B2.5', - ' repository and corresponding labels for the webpage, see the "versions.yaml"', + 'path to a "versions.yaml" file containing the list of git refs in the B2.5' + ' repository and corresponding labels for the webpage, see the "versions.yaml"' ' file in this repo for more information' )) parser.add_argument('-d', '--dest-dir', default='.', help=( 'destination directory for the fetched files, will be created if it' ' does not exist, default="."' )) -parser.add_argument('-a', '--auth', default=None, help=( - 'username and access token in format "user:token" with read-only access to git.iter.org,' - ' will attempt to read it from the GIT_ITER_USER and GIT_ITER_TOKEN env vars if this parameter is not specified' -)) parser.add_argument('-v', '--verbose', action='store_true', help=( 'print logging output' )) @@ -103,21 +76,7 @@ def fetch_all_versions(git_user, git_token, versions_yaml, dest_dir): else: pass - if args.auth is not None: - try: - git_user, git_token = args.auth.split(':') - except ValueError: - raise RuntimeError('Invalid auth format, expected "user:token"') - elif 'GIT_ITER_USER' in os.environ and 'GIT_ITER_TOKEN' in os.environ: - git_user = os.environ['GIT_ITER_USER'] - git_token = os.environ['GIT_ITER_TOKEN'] - else: - raise RuntimeError( - 'If auth credentials are not provided (--token), GIT_ITER_USER and GIT_ITER_TOKEN env vars must be set') - fetch_all_versions( - git_user=git_user, - git_token=git_token, versions_yaml=args.versions_yaml, dest_dir=args.dest_dir, ) From 2963938bd39e885919148c731d8c679a2047b509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20He=C4=8Dko?= Date: Wed, 2 Sep 2026 14:36:23 +0200 Subject: [PATCH 2/5] Update b2input version list --- extras/b2input/versions.yaml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/extras/b2input/versions.yaml b/extras/b2input/versions.yaml index a5f0d06..49f9083 100644 --- a/extras/b2input/versions.yaml +++ b/extras/b2input/versions.yaml @@ -5,13 +5,15 @@ versions: - git_ref: refs/heads/develop - label: 3.0.9@develop - - git_ref: refs/heads/release/3.1.1 - label: 3.1.1 - - git_ref: refs/heads/feature/wg_workflow - label: 3.2.0@wg_workflow - - git_ref: refs/tags/3.0.8 - label: 3.0.8@old + label: develop + - git_ref: refs/tags/3.0.10a + label: 3.0.10a + - git_ref: refs/tags/3.1.2a + label: 3.1.2a + - git_ref: refs/tags/3.2.1a + label: WG-3.2.1a + - git_ref: refs/heads/feature/wg-release + label: WG-3.2.0@wg_release # The `xhtml-symbol.ent` file is not really changed often, thus we assume # that it's ok to pick one recent version and share it for all `b2input.xml` versions. From affcbf977add9617971000cc15a9e579d85d4909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20He=C4=8Dko?= Date: Wed, 2 Sep 2026 14:43:31 +0200 Subject: [PATCH 3/5] Update readme for b2input --- .gitignore | 2 ++ extras/b2input/README.md | 2 +- extras/b2input/src_html/index_toplevel_template.html | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 065fd11..e10bd40 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ builds public +docs/extras +extras/b2input/fetched /venv __pycache__/ diff --git a/extras/b2input/README.md b/extras/b2input/README.md index 7dac023..7e820af 100644 --- a/extras/b2input/README.md +++ b/extras/b2input/README.md @@ -37,7 +37,7 @@ python generate_html.py -d "./public" /path/to/solps-iter/modules/B2.5/src/docum ### Advanced usage (in CI pipeline) -There is a second script, which can download the `b2input.xml` files for one or more SOLPS-ITER versions directly from its git repository. Requires a `versions.yaml` file analogous to the one found in this repository and a read-access token, see [https://git.iter.org/account](https://git.iter.org/account) -> HTTP access tokens. +There is a second script, which can download the `b2input.xml` files for one or more SOLPS-ITER versions directly from its git repository. Requires a `versions.yaml` file analogous to the one found in this repository. ```bash python fetch_b2input_xml_files.py --help diff --git a/extras/b2input/src_html/index_toplevel_template.html b/extras/b2input/src_html/index_toplevel_template.html index bfca3b3..945209d 100644 --- a/extras/b2input/src_html/index_toplevel_template.html +++ b/extras/b2input/src_html/index_toplevel_template.html @@ -18,13 +18,13 @@ {% block content %}
-
+
Last updated on {{ current_date.strftime('%Y-%m-%d') }}
-

Kept up-to-date via automated gitlab pipeline.

+
From 1d952f0b7790c4706abf4d11ff12ba413cd1690e Mon Sep 17 00:00:00 2001 From: hetsko <50210960+hetsko@users.noreply.github.com> Date: Wed, 2 Sep 2026 16:31:33 +0200 Subject: [PATCH 4/5] Add gh workflow to test the build process --- .github/workflows/test.yml | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..cfc2b61 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,60 @@ +name: Test Build + +on: + push: + branches: [ master, feature/update-b2input-viewer ] + pull_request: + branches: [ master ] + +jobs: + test-mkdocs: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - name: Set up Python + uses: actions/setup-python@v7 + with: + python-version: '3.12' + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Test build MkDocs site + run: mkdocs build --strict --verbose + + test-b2input: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - name: Set up Python + uses: actions/setup-python@v7 + with: + python-version: '3.12' + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + # Note: Testing the same command as in .readthedocs.yaml + - name: Test fetch b2input.xml files + run: python extras/b2input/fetch_b2input_xml_files.py + --verbose + --dest-dir extras/b2input/fetched + extras/b2input/versions.yaml + + # Note: Testing the same command as in .readthedocs.yaml + - name: Test generate b2input viewer HTML pages + run: python extras/b2input/generate_html.py + --verbose + --source-dir extras/b2input + --dest-dir docs/extras/b2input + extras/b2input/fetched From 795cb9f57375a6a8a92a3adcc666adc20494f459 Mon Sep 17 00:00:00 2001 From: hetsko <50210960+hetsko@users.noreply.github.com> Date: Wed, 2 Sep 2026 16:33:19 +0200 Subject: [PATCH 5/5] Add RTD config --- .github/workflows/test.yml | 2 +- .readthedocs.yaml | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .readthedocs.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cfc2b61..3daa4f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,7 @@ name: Test Build on: push: - branches: [ master, feature/update-b2input-viewer ] + branches: [ master ] pull_request: branches: [ master ] diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..80a62d7 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,26 @@ +version: 2 + +build: + os: ubuntu-24.04 + tools: + python: "3.12" + jobs: + pre_build: + # Generating b2input.xml viewer webpages + - python extras/b2input/fetch_b2input_xml_files.py + --verbose + --dest-dir extras/b2input/fetched + extras/b2input/versions.yaml + - python extras/b2input/generate_html.py + --verbose + --source-dir extras/b2input + --dest-dir docs/extras/b2input + extras/b2input/fetched + + +mkdocs: + configuration: mkdocs.yml + +python: + install: + - requirements: requirements.txt