[v5.5] Diagnostics UI: model/log viewer + ModelFile page + MathJax#408
[v5.5] Diagnostics UI: model/log viewer + ModelFile page + MathJax#408lil-aditya wants to merge 6 commits intoEAPD-DRB:mainfrom
Conversation
|
This PR is based on the PR2 branch since upstream main did not yet include PR2 in this checkout. |
There was a problem hiding this comment.
Pull request overview
Ports the upstream v5.5 diagnostics UI into MUIOGO by adding model/log viewers, a standalone ModelFile equations page, and supporting backend routes/guardrails for safe diagnostics reads.
Changes:
- Added DataFile-page controls and modals for viewing the fixed-path model/log text, plus a scenario toggle-all control.
- Introduced a standalone
#/ModelFilepage that parses GMPL constraints and typesets them with MathJax. - Added backend fixed-path routes (
/readModelFile,/readLogFile), runtime logging location changes, and a smoke/clean-base verification harness + CI workflow.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| WebAPP/SOLVERs/model.v.5.4.txt | Minor formatting tweaks in solver model text; used by equations extraction/rendering. |
| WebAPP/Routes/Routes.Class.js | Adds SPA route for #/ModelFile. |
| WebAPP/index.html | Adds MathJax configuration + CDN script include. |
| WebAPP/Classes/Osemosys.Class.js | Adds frontend helpers for readModelFile / readLogFile via fetch. |
| WebAPP/Classes/Html.Class.js | Adds safe plain-text rendering helpers for model/log/data text. |
| WebAPP/App/View/ModelFile.html | New equations page layout + styles. |
| WebAPP/App/View/DataFile.html | Adds EQUATIONS / VIEW MODEL / VIEW LOG controls, toggle-all button, and model/log modals. |
| WebAPP/App/Controller/ModelFile.js | New controller: extracts objective/constraints and typesets with MathJax. |
| WebAPP/App/Controller/DataFile.js | Adds modal text viewer helper and scenario toggle-all behavior. |
| API/Routes/DataFile/DataFileRoute.py | Adds fixed-path read endpoints and improves logging around runs. |
| API/Classes/Base/Config.py | Introduces runtime/log directory configuration and solver model path constant. |
| API/app.py | Adds rotating file logging setup and warning capture. |
| API/Classes/Case/OsemosysClass.py | Refactors path bookkeeping (results/view/resData paths) and solver model file reference. |
| API/Classes/Case/DataFileClass.py | Refactors case run creation/update/cleanup to use instance paths and preserve viewDefinitions. |
| tests_smoke/test_smoke_app.py | Adds stdlib unittest smoke coverage for app import and fixed routes. |
| scripts/verify_clean_base.py | Adds “clean-base” verification script (git state, conflict markers, py_compile, smoke tests). |
| docs/dev/upstream_sync_playbook.md | Documents upstream sync order, overlap surface, rejected patterns, and verification command. |
| CONTRIBUTING.md | Adds clean-base verification guidance and pointers to the playbook. |
| .github/workflows/smoke.yml | Runs clean-base verification in CI on pull requests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| # Energy balance – include only pairs that exist (others implicitly 0) | ||
| # Energy balance � include only pairs that exist (others implicitly 0) |
There was a problem hiding this comment.
The comment line contains a replacement character ("�"), which suggests an encoding/typography corruption (likely meant to be an en dash). Since this file is solver input, please replace it with plain ASCII (e.g., "-"), or ensure the intended character is preserved reliably.
| # Energy balance � include only pairs that exist (others implicitly 0) | |
| # Energy balance - include only pairs that exist (others implicitly 0) |
| <script> | ||
| window.MathJax = window.MathJax || { | ||
| tex: { | ||
| packages: { '[+]': ['ams'] }, | ||
| inlineMath: [['\\(', '\\)']], |
There was a problem hiding this comment.
MathJax is being configured and loaded in the global entrypoint, which means every page load pulls MathJax even when the equations view isn't used. This also conflicts with the PR description claim that MathJax is scoped to the equation page only; consider loading/injecting MathJax only when the ModelFile route/view is entered.
| <!-- Swap this CDN src later if MathJax is vendored locally. --> | ||
| <script id="muiogo-mathjax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" defer></script> |
There was a problem hiding this comment.
The MathJax CDN URL is not version-pinned ("mathjax@3"), so it can change underneath you. Pin to a specific version and consider adding an integrity/crossorigin policy (or vendoring locally) to reduce supply-chain risk.
| <!-- Swap this CDN src later if MathJax is vendored locally. --> | |
| <script id="muiogo-mathjax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" defer></script> | |
| <!-- MathJax CDN is version-pinned; swap this src later if MathJax is vendored locally. --> | |
| <script id="muiogo-mathjax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-chtml.js" defer></script> |
| equation.latex, | ||
| '\\end{align}', | ||
| `\\tag{${counter}}`, |
There was a problem hiding this comment.
The generated MathJax block puts \tag{} after \end{align}. In LaTeX/MathJax, \tag must be inside an ams math environment (e.g., within align/equation) or it may be ignored / throw a typeset error. Move the tag into the align environment (or use an environment that supports tagging as written).
| equation.latex, | |
| '\\end{align}', | |
| `\\tag{${counter}}`, | |
| `${equation.latex} \\tag{${counter}}`, | |
| '\\end{align}', |
| }else{ | ||
| Html.renderScOrder(model.scenarios); | ||
| } | ||
| DataFile.syncScenarioToggleButton(); |
There was a problem hiding this comment.
The toggle-all button label/icon is only synced when the modal opens and when toggle-all is clicked. If a user manually checks/unchecks individual scenario checkboxes, the toggle-all label can become stale. Add a change handler on '#osy-scOrder' checkbox inputs to call syncScenarioToggleButton() after any manual toggle.
| DataFile.syncScenarioToggleButton(); | |
| DataFile.syncScenarioToggleButton(); | |
| // Keep toggle-all button state in sync when individual scenario checkboxes change | |
| $("#osy-scOrder") | |
| .off("change", "input[type='checkbox']") | |
| .on("change", "input[type='checkbox']", function () { | |
| DataFile.syncScenarioToggleButton(); | |
| }); |
Closes: #391
Part of: #388
Requires: PR1 (guardrails) and PR2 (backend/runtime routes) to be merged
Summary
This PR ports the upstream MUIO v5.5 diagnostics UI into MUIOGO, including:
Changes included
Compatibility + Safety
Narrow upstream adaptations
The upstream UI was followed by default, with minimal, targeted changes:
Files touched (frontend scope)
Validation
git diff --checkpassed (no whitespace/syntax issues)Known limitations
readModelFile,readLogFile)End-to-end UI validation is expected in CI / reviewer environment.
Out of scope
Notes
This PR intentionally keeps changes minimal and aligned with upstream v5.5 UI behavior, while enforcing MUIOGO’s safety constraints for path handling and rendering.