-
Notifications
You must be signed in to change notification settings - Fork 16
Add SimBoard-compatible www inference via a new [simboard] config section
#841
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
Merged
chengzhuzhang
merged 18 commits into
main
from
copilot/update-default-www-and-simboard-type
Aug 24, 2026
+1,094
−31
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a70259d
Implement inferred simboard www defaults
Copilot d7d426f
Refine simboard default coverage
Copilot 0c190f4
Add explicit simboard publishing config
Copilot 1d1921a
Tighten simboard config messaging
Copilot 3da1fee
Clarify simboard task intent
Copilot 32e13ff
Clean up simboard validation helpers
Copilot e6e0f1e
Harden simboard config checks
Copilot 3d66474
Clarify simboard validation assumptions
Copilot ee45ff1
Add simboard helper coverage
Copilot 5198b18
Fix pre-commit errors
forsyth2 de3b2a0
Fix NoOptionError crash before SimBoard www inference
Copilot bfa34d4
Add docs for the new [simboard] configuration section
Copilot 230c8cf
Add dry-run simboard integration settings tests
Copilot 41892d0
Change simulation_type default to "development"; update docs
Copilot 162d4e3
Minor doc rewording
forsyth2 d0935cc
Skip www writes on a dry run
chengzhuzhang 40ac3d1
Add case_group to provenance and the inferred SimBoard path
chengzhuzhang 9f6415b
docs(simboard): align zppy SimBoard page with new diagnostics linkage…
forsyth2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| .. _task-simboard: | ||
|
tomvothecoder marked this conversation as resolved.
|
||
|
|
||
| simboard — SimBoard Publishing Configuration | ||
| ============================================ | ||
|
|
||
| The ``simboard`` section is a configuration-only hook that controls | ||
| SimBoard-compatible publishing behavior. Like :doc:`bundle`, it does not | ||
| launch an HPC job of its own; instead it influences how other tasks are | ||
| configured — specifically, it can infer the ``www`` output path from the | ||
| machine's Mache configuration. | ||
|
|
||
| When ``enabled = True`` and ``www`` is left empty in ``[default]``, | ||
| ``zppy`` derives ``www`` from the ``web_portal.base_path`` recorded in | ||
| Mache for the current machine: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| <web_portal_base_path>/diagnostics_archive/<simulation_type>/ | ||
|
|
||
| This gives SimBoard a single, predictable archive root to scan for | ||
| diagnostics. | ||
|
|
||
| Expected behavior | ||
| ----------------- | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 20 15 65 | ||
|
|
||
| * - ``simboard.enabled`` | ||
| - ``www`` | ||
| - Behavior | ||
| * - ``False`` | ||
| - any | ||
| - ``zppy`` does nothing SimBoard-specific. | ||
| * - ``True`` | ||
| - empty | ||
| - Infer the SimBoard archive path from Mache's | ||
| ``web_portal.base_path``. | ||
| * - ``True`` | ||
| - set | ||
| - Use the explicit ``www`` path and do not override it. | ||
| ``simboard.enabled`` still controls SimBoard-specific validation | ||
| (e.g., ``simulation_type`` must not be ``"none"``). | ||
| * - ``True`` | ||
| - empty, but path cannot be inferred | ||
| - Raise a clear configuration error. | ||
|
|
||
| Configuration example | ||
| --------------------- | ||
|
|
||
| .. code-block:: cfg | ||
|
|
||
| [default] | ||
| case = v3.LR.historical_0051 | ||
| input = /path/to/input | ||
| output = /path/to/output | ||
| # Leave www empty to let zppy infer it from Mache when simboard is enabled. | ||
| www = | ||
|
|
||
| [simboard] | ||
| enabled = True | ||
| simulation_type = production | ||
|
|
||
| Parameters | ||
| ---------- | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 22 10 18 50 | ||
|
|
||
| * - Parameter | ||
| - Required | ||
| - Default | ||
| - Description | ||
| * - ``enabled`` | ||
| - No | ||
| - ``False`` | ||
| - Set to ``True`` to enable SimBoard-compatible publishing behavior. | ||
| When enabled and ``[default] www`` is empty, ``zppy`` infers | ||
| ``www`` from Mache's ``web_portal.base_path``. | ||
| * - ``simulation_type`` | ||
| - No | ||
| - ``"production"`` | ||
| - Diagnostic classification for the archive path. One of | ||
| ``"production"``, ``"development"``, or ``"none"``. | ||
| Must not be ``"none"`` when ``enabled = True``. | ||
|
|
||
| .. note:: | ||
| The ``[simboard]`` section does not support subsections. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,132 @@ | ||||||||
| import ast | ||||||||
| import configparser | ||||||||
| import re | ||||||||
| from pathlib import Path | ||||||||
| from typing import Any, Dict, Optional | ||||||||
| from unittest.mock import MagicMock | ||||||||
|
|
||||||||
| import pytest | ||||||||
| from configobj import ConfigObj | ||||||||
| from validate import Validator | ||||||||
|
|
||||||||
| from zppy.__main__ import _determine_parameters | ||||||||
| from zppy.utils import write_settings_file | ||||||||
|
|
||||||||
| _WEB_PORTAL_BASE_PATH = "/global/cfs/cdirs/e3sm/www" | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a Perlmutter-specific path, but that's fine because we're just doing dry-run testing here. |
||||||||
|
|
||||||||
|
|
||||||||
| def _default_ini_path() -> Path: | ||||||||
| return Path(__file__).resolve().parents[2] / "zppy" / "defaults" / "default.ini" | ||||||||
|
|
||||||||
|
|
||||||||
| def _write_cfg(tmp_path: Path, *, www: str, simboard_enabled: bool) -> Path: | ||||||||
| config_path = tmp_path / "simboard_settings.cfg" | ||||||||
| config_path.write_text( | ||||||||
| "\n".join( | ||||||||
| [ | ||||||||
| "[default]", | ||||||||
| "case = test_case", | ||||||||
| "input = /input", | ||||||||
| f"output = {tmp_path / 'output'}", | ||||||||
| "dry_run = True", | ||||||||
| "machine = pm-cpu", | ||||||||
| f"www = {www}", | ||||||||
| "", | ||||||||
| "[simboard]", | ||||||||
| f"enabled = {'True' if simboard_enabled else 'False'}", | ||||||||
| "simulation_type = production", | ||||||||
| "", | ||||||||
| ] | ||||||||
| ) | ||||||||
| ) | ||||||||
| return config_path | ||||||||
|
|
||||||||
|
|
||||||||
| def _validated_config(config_path: Path) -> ConfigObj: | ||||||||
| config = ConfigObj(str(config_path), configspec=str(_default_ini_path())) | ||||||||
| validation_result = config.validate(Validator()) | ||||||||
| assert validation_result is True | ||||||||
| return config | ||||||||
|
|
||||||||
|
|
||||||||
| def _fake_machine_info( | ||||||||
| web_portal_base_path: Optional[str] = _WEB_PORTAL_BASE_PATH, | ||||||||
| ) -> MagicMock: | ||||||||
| machine_config = configparser.ConfigParser() | ||||||||
| machine_config["e3sm_unified"] = {"base_path": "/unified"} | ||||||||
| machine_config["diagnostics"] = {"base_path": "/diagnostics"} | ||||||||
| machine_config["web_portal"] = {"base_url": "https://portal.nersc.gov/cfs/e3sm"} | ||||||||
| if web_portal_base_path is not None: | ||||||||
| machine_config["web_portal"]["base_path"] = web_portal_base_path | ||||||||
|
|
||||||||
| machine_info = MagicMock() | ||||||||
| machine_info.machine = "pm-cpu" | ||||||||
| machine_info.config = machine_config | ||||||||
| machine_info.get_account_defaults.return_value = ("e3sm", "regular", "cpu", None) | ||||||||
| return machine_info | ||||||||
|
|
||||||||
|
|
||||||||
| def _write_default_settings(tmp_path: Path, config: ConfigObj) -> Path: | ||||||||
| settings_path = tmp_path / "resolved_default.settings" | ||||||||
| write_settings_file(str(settings_path), dict(config["default"]), (1, 1)) | ||||||||
| return settings_path | ||||||||
|
|
||||||||
|
|
||||||||
| def _read_default_settings(settings_path: Path) -> Dict[str, Any]: | ||||||||
| settings_text = settings_path.read_text() | ||||||||
| parsed_settings = ast.parse(settings_text, mode="exec") | ||||||||
| assert parsed_settings.body | ||||||||
| first_expression = parsed_settings.body[0] | ||||||||
| assert isinstance(first_expression, ast.Expr) | ||||||||
| default_settings = ast.literal_eval(first_expression.value) | ||||||||
| assert isinstance(default_settings, dict) | ||||||||
| return default_settings | ||||||||
|
|
||||||||
|
|
||||||||
| def test_simboard_disabled_preserves_explicit_www(tmp_path: Path) -> None: | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checks this condition:
|
||||||||
| config_path = _write_cfg( | ||||||||
| tmp_path, www="/some/explicit/path", simboard_enabled=False | ||||||||
| ) | ||||||||
| config = _validated_config(config_path) | ||||||||
|
|
||||||||
| updated_config = _determine_parameters(_fake_machine_info(), config) | ||||||||
| settings_path = _write_default_settings(tmp_path, updated_config) | ||||||||
| default_settings = _read_default_settings(settings_path) | ||||||||
|
|
||||||||
| assert default_settings["www"] == "/some/explicit/path" | ||||||||
|
|
||||||||
|
|
||||||||
| def test_simboard_enabled_infers_www_from_machine_info(tmp_path: Path) -> None: | ||||||||
|
tomvothecoder marked this conversation as resolved.
|
||||||||
| config_path = _write_cfg(tmp_path, www="", simboard_enabled=True) | ||||||||
| config = _validated_config(config_path) | ||||||||
| expected_www = f"{_WEB_PORTAL_BASE_PATH}/diagnostics_archive/production/" | ||||||||
|
|
||||||||
| updated_config = _determine_parameters(_fake_machine_info(), config) | ||||||||
| settings_path = _write_default_settings(tmp_path, updated_config) | ||||||||
| default_settings = _read_default_settings(settings_path) | ||||||||
|
|
||||||||
| assert default_settings["www"] == expected_www | ||||||||
|
|
||||||||
|
|
||||||||
| def test_simboard_enabled_preserves_explicit_www(tmp_path: Path) -> None: | ||||||||
|
tomvothecoder marked this conversation as resolved.
|
||||||||
| config_path = _write_cfg(tmp_path, www="/custom/path", simboard_enabled=True) | ||||||||
| config = _validated_config(config_path) | ||||||||
|
|
||||||||
| updated_config = _determine_parameters(_fake_machine_info(), config) | ||||||||
| settings_path = _write_default_settings(tmp_path, updated_config) | ||||||||
| default_settings = _read_default_settings(settings_path) | ||||||||
|
|
||||||||
| assert default_settings["www"] == "/custom/path" | ||||||||
|
|
||||||||
|
|
||||||||
| def test_simboard_enabled_empty_www_requires_inferable_path(tmp_path: Path) -> None: | ||||||||
|
tomvothecoder marked this conversation as resolved.
|
||||||||
| config_path = _write_cfg(tmp_path, www="", simboard_enabled=True) | ||||||||
| config = _validated_config(config_path) | ||||||||
| expected_message = ( | ||||||||
| "www is empty and simboard.enabled is True, but machine 'pm-cpu' " | ||||||||
| "has no web_portal.base_path in mache; cannot infer a " | ||||||||
| "diagnostics_archive path." | ||||||||
| ) | ||||||||
|
|
||||||||
| with pytest.raises(ValueError, match=re.escape(expected_message)): | ||||||||
| _determine_parameters(_fake_machine_info(web_portal_base_path=None), config) | ||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.