Skip to content

chore: clean up unused constants/imports + fix jupyter-lab-server CLI registration - #1058

Merged
lior-antonov merged 4 commits into
masterfrom
deadcode/cleanup-constants-imports
Aug 30, 2026
Merged

chore: clean up unused constants/imports + fix jupyter-lab-server CLI registration#1058
lior-antonov merged 4 commits into
masterfrom
deadcode/cleanup-constants-imports

Conversation

@ilayfalach

Copy link
Copy Markdown
Collaborator

Summary

Smaller cleanups: removes unused constants (DOCTYPE_STATIONS/DOCTYPE_MEASUREMENTS, TOOLKIT_VECTOR_REGIONNAME, LSMToolkit.TRUE/FALSE, LSMTemplate.STABILITY_*) and unused imports. Plus two real fixes:

  • hera/bin/jupyter-lab-server didn't match the hera-* glob in setup.py and was silently never installed despite being documented — renamed to hera-jupyter-lab-server (git mv) and updated all doc/notebook references.
  • Documented the previously-unset PYARGOS_PATH env var in docs/configuration/env_vars.md.

10 files changed. Full detail in the "5. cleanup-constants-imports" section of #1022.

Verification: python3 -m py_compile on all touched files.

⚠️ Not merged/approved by me — opened for review only.

Refs #1022

Comment thread docs/cli/reference.md
Comment thread hera/bin/hera-jupyter-lab-server
Comment thread hera/doc/jupyter/Developer/toolkits/RiskAnalysis.ipynb
Comment thread hera/doc/jupyter/User/toolkits/RiskAnalysis.ipynb
Comment thread hera/simulations/LSM/toolkit.py
Ilay Falach and others added 4 commits August 27, 2026 14:35
- Remove unused HighFreqToolKit.DOCTYPE_STATIONS / DOCTYPE_MEASUREMENTS
- Remove unused TOOLKIT_VECTOR_REGIONNAME constant in vector toolkit
- Remove unused LSMToolkit.TRUE/FALSE constants (template.py uses hardcoded
  ".TRUE."/".FALSE." literals directly)
- Remove unused LSMTemplate.STABILITY_NEUTRAL/STABLE/UNSTABLE constants
- Remove unused CASETYPE_RECONSTRUCTED import and unused hera_logging
  import in pvOpenFOAMBase.py

Confirmed unreferenced via repo-wide grep before removal.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
setup.py builds scripts=[...] via glob.glob("hera/bin/hera-*"), which only
matches files whose basename starts with "hera-". The Jupyter Lab launcher
script was named "jupyter-lab-server" and therefore silently never got
installed, despite being documented in docs/cli/reference.md as a
first-class CLI entry point alongside hera-ui, hera-experiment, etc.

Rename it to hera-jupyter-lab-server (via git mv, preserving history) so
it matches the glob, and update all references to the old name in
docs/cli/reference.md and the RiskAnalysis example notebooks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
hera/tests/dynamic_loading_tests_pack/test_experiment_cli_shortcuts.py
reads os.environ["PYARGOS_PATH"] to optionally point the experiment CLI
tests at a local pyargos-master installation, but this env var was never
documented anywhere in the repo. Add an entry alongside the other testing
variables (HERA_FULL_LOGGING_TESTS, RESULT_SET, GDF_TOL_AREA, etc.) in
docs/configuration/env_vars.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Per @lior-antonov's review:

- Reverted the hera-jupyter-lab-server rename; the script keeps its
  original name jupyter-lab-server, and docs/cli/reference.md and both
  RiskAnalysis notebooks are restored to master state (this PR no longer
  touches them). Fixed the underlying bug differently instead: setup.py
  only globbed hera/bin/hera-*, so the script was never installed
  despite being documented. It is now listed explicitly.

- Restored LSMToolkit.TRUE / LSMToolkit.FALSE and used them at all six
  places in LSM/template.py that hardcoded ".TRUE." / ".FALSE.",
  including the fileDict at line 111. The lowercase ".true." / ".false."
  keys have no constants and stay as literals, so fileDict keeps the
  same four keys and values.

LSMTemplate.STABILITY_NEUTRAL/STABLE/UNSTABLE stay removed: unlike
TRUE/FALSE they have no intended call site — no "neutral"/"stable"/
"unstable" literal appears anywhere in hera/simulations/LSM/.

Refs #1022
@ilayfalach
ilayfalach force-pushed the deadcode/cleanup-constants-imports branch from e1e4750 to eaeff9f Compare August 27, 2026 11:47
@ilayfalach

Copy link
Copy Markdown
Collaborator Author

@lior-antonov all five comments handled — replies in the threads.

The rename: reverted, bug fixed differently

The script keeps the name jupyter-lab-server. docs/cli/reference.md and both RiskAnalysis.ipynb files are restored to master state, so this PR no longer touches any of the four files you commented on.

The underlying bug is still fixed, just without renaming. setup.py registered scripts via glob.glob("hera/bin/hera-*"), so jupyter-lab-server never matched and was never installed, despite being documented. It's now listed explicitly:

scripts=[s for s in glob.glob("hera/bin/hera-*") if not s.endswith(".old")]
        + ["hera/bin/jupyter-lab-server"],

Worth noting: the notebook edits were doing more damage than the rename. They also flattened the source array into a single JSON string and stripped the trailing newline — artifacts of programmatic JSON rewriting. Both are gone now too.

LSM constants: wired up at all six sites

LSMToolkit.TRUE/FALSE restored and used everywhere template.py hardcoded the literals — lines 111 (your fileDict), 124, 128, 136, 138, 140. Zero literals left.

Verified fileDict is provably unchanged: the lowercase ".true."/".false." keys have no constants and stay literal, and I asserted at runtime that both forms produce the same four keys and values. Also confirmed self.Toolkit can't be None at line 111 — it's a required __init__ arg, and line 113 already dereferences it unguarded.

Left removed: LSMTemplate.STABILITY_NEUTRAL/STABLE/UNSTABLE. Unlike TRUE/FALSE these have no intended call site — no "neutral"/"stable"/"unstable" literal exists anywhere in hera/simulations/LSM/. Point me at where they belong and I'll wire them up the same way.

Rebased

The branch was 35 commits behind master; rebased cleanly. Since #1054 merged and touched pvOpenFOAMBase.py, I re-verified the removals there against current master: CASETYPE_RECONSTRUCTED and hera_logging have zero uses in that file. TOOLKIT_VECTOR_REGIONNAME, DOCTYPE_STATIONS, and DOCTYPE_MEASUREMENTS have zero uses repo-wide.

Verification

py_compile on all touched files — clean. setup.py parses and its script list resolves to 14 entries with no missing files. LSMTemplate/LSMToolkit import; TRUE/FALSE hold the right values; STABILITY_* confirmed gone.

Down from 10 files to 6.

@lior-antonov
lior-antonov merged commit 2f2cd59 into master Aug 30, 2026
1 check passed
@lior-antonov
lior-antonov deleted the deadcode/cleanup-constants-imports branch August 30, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants