Skip to content

Tooling dedup: gen_case_constraints_docs.py (c), sched.py (d), user_guide.py (e) - #1720

Open
AnaPcode wants to merge 4 commits into
MFlowCode:masterfrom
AnaPcode:feature/tooling-dedup
Open

Tooling dedup: gen_case_constraints_docs.py (c), sched.py (d), user_guide.py (e)#1720
AnaPcode wants to merge 4 commits into
MFlowCode:masterfrom
AnaPcode:feature/tooling-dedup

Conversation

@AnaPcode

Copy link
Copy Markdown

Description

Addresses (a), (c), (d), (e) from issue 1512, following the specific fixes the issue suggested for each file except for (a).

(a) fp_stability.py - no changes made. The file seems to have changed since the issue was filed (now 693 lines), and the cited line numbers (970-983, 1322-1335) no longer correspond to the described code. Found a _blank_result(name) helper already present, but couldn't locate a dict matching the original 13-key description anywhere in the file. Is this still an open issue, or can it be considered addressed?

(c) gen_case_constraints_docs.py - two separate dedups:

The level emoji map was duplicated in render_playbook_card (line 159) and generate_playbook (line 267). Moved it to a LEVEL_EMOJI constant, placed after PlaybookEntry, and pointed both call sites at it.

get_model_name, get_riemann_solver_name, and get_time_stepper_name (lines 133-151) had byte-identical bodies modulo the schema key string. Replaced all three with a single _named(param, value) helper and updated the three call sites: line 170 (model_eqns), line 222 (riemann_solver), and line 226 (time_stepper).

(d) sched.py - the seconds were hardcoded at each comparison in notify_long_running_threads, while only the message text indexed the HEADLESS_THRESHOLDS table. Comparisons now read the seconds from the table too.

(e) user_guide.py - all 8 entries in ORG_COLORS mapped to "yellow", and the lookup defaulted to "yellow" anyway, so every org rendered yellow regardless. Deleted the dictionary and inlined "yellow" directly at the lookup site. Chose not to give orgs distinct colors, since that's a user-facing change and I could not identify what information/benefit color-coding would add across the 9 orgs. May be worth its own feature-request issue if that's actually wanted.

All changes are mechanical and behavior-preserving, no functional or output changes are intended.

Type of change

  • Refactor

Testing

These changes are cleanups in the toolchain Python files, with no build-system or Fortran impact, so I verified behavior preservation directly rather than through the test suite. For two of the files, gen_case_constraints_docs.py and user_guide.py, I compared generated output before and after my changes. To do this I created a temporary copy of the original master branch alongside my working copy, so I could run both versions side by side. sched.py is time-dependent, so I verified it by value instead.

gen_case_constraints_docs.py - I ran main(), the entry point that generates the case constraint documentation, and compared outputs from both the original file and the file with changes. Outputs were the same. The path covered both changes in this file: it calls render_playbook_card(), which uses _named, and both it and generate_playbook() use LEVEL_EMOJI.

user_guide.py - same comparison on _generate_clusters_content(). Outputs were identical, and all orgs still render yellow.

sched.py - prints only after minutes of real elapsed time, so I compared values rather than output. The table holds 120, 600, and 1800 seconds, the same numbers as the 2 * 60, 10 * 60, 30 * 60 literals they replaced.

I also used file hashes (a way to confirm two files are byte-for-byte identical) as an extra check on top of the direct comparisons for gen_case_constraints_docs.py outputs and user_guide.py outputs where both matched.

Commands used for testing

bash cd ~/MFC mkdir -p ~/mfc-verify git worktree add /tmp/original_master master ​

1. gen_case_constraints_docs.py

​```bash
cd /tmp/original_master && python3 -c 'import sys; sys.path.insert(0,"toolchain")
from mfc.gen_case_constraints_docs import main; main()' > ~/mfc-verify/docs_before.txt

cd ~/MFC && python3 -c 'import sys; sys.path.insert(0,"toolchain")
from mfc.gen_case_constraints_docs import main; main()' > ~/mfc-verify/docs_after.txt

diff ~/mfc-verify/docs_before.txt ~/mfc-verify/docs_after.txt && echo "gen_case_constraints_docs.py: NO CHANGE"
​```

2. user_guide.py

​```bash
cd /tmp/original_master && python3 -c 'import sys; sys.path.insert(0,"toolchain")
from mfc.user_guide import _generate_clusters_content as f; print(f())' > ~/mfc-verify/guide_before.txt

cd ~/MFC && python3 -c 'import sys; sys.path.insert(0,"toolchain")
from mfc.user_guide import _generate_clusters_content as f; print(f())' > ~/mfc-verify/guide_after.txt

diff ~/mfc-verify/guide_before.txt ~/mfc-verify/guide_after.txt && echo "user_guide.py: NO CHANGE"
​```

3. sched.py

bash cd ~/MFC && python3 -c 'import sys; sys.path.insert(0,"toolchain") from mfc.sched import HEADLESS_THRESHOLDS as H print(H[0][0], H[1][0], H[2][0], "should be", 2*60, 10*60, 30*60)' ​
Result:
120 600 1800 should be 120 600 1800 ​

Proof (hashes)

bash shasum ~/mfc-verify/*.txt ​
Result:
3016ca54d8cafc7fed2e41f49ac3fd4dd2cababd ~/mfc-verify/docs_after.txt 3016ca54d8cafc7fed2e41f49ac3fd4dd2cababd ~/mfc-verify/docs_before.txt a22ed36dc99d289c79f9c9dae2486fe2b5a5f5d6 ~/mfc-verify/guide_after.txt a22ed36dc99d289c79f9c9dae2486fe2b5a5f5d6 ~/mfc-verify/guide_before.txt ​

Cleanup

bash cd ~/MFC && git worktree remove /tmp/original_master ​

Part of #1512

“AnaPcode” added 4 commits August 8, 2026 16:12
Was duplicated in render_playbook_card (line 159) and generate_playbook (line 267). Moved to a LEVEL_EMOJI constant, placed after PlaybookEntry, and pointed both call sites at it.

Part of MFlowCode#1512 cleanup of tooling file (c)
get_model_name, get_riemann_solver_name, and get_time_stepper_name (lines 133-151) had byte-identical bodies modulo the schema key string. Replaced all three with a single _named(param, value) helper and updated the three call sites: line 170 (model_eqns), line 222 (riemann_solver), and line 226 (time_stepper).

Part of issue 1512 cleanup of tooling file (c)
The seconds were hardcoded at each comparison in notify_long_running_threads, while only the message text indexed the HEADLESS_THRESHOLDS table. Read the seconds from this table too, so they live in one place.

Part of issue 1512 cleanup of tooling file (d)
All 8 entries in ORG_COLORS mapped to "yellow" and the lookup defaulted to "yellow", so every org rendered yellow regardless. Deleted the dictionary and inlined yellow.

Part of issue 1512 cleanup of tooling file (e)
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.24%. Comparing base (8dfe8c7) to head (065e86f).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1720      +/-   ##
==========================================
+ Coverage   60.77%   61.24%   +0.46%     
==========================================
  Files          83       83              
  Lines       20872    20700     -172     
  Branches     3101     3072      -29     
==========================================
- Hits        12685    12677       -8     
+ Misses       6121     5969     -152     
+ Partials     2066     2054      -12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant