Centralise configuration, sample naming and Origin connection - #2
Open
jongsu-king wants to merge 1 commit into
Open
Centralise configuration, sample naming and Origin connection#2jongsu-king wants to merge 1 commit into
jongsu-king wants to merge 1 commit into
Conversation
Centralise configuration, sample naming and Origin connection
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Centralise configuration, sample naming and Origin connectionSeven modules each re-derived the location of
physisfera_config.jsonfrom their own__file__with a hand-counted chain of.., and read the file independently. This consolidates that into one reader, and fixes the three defects the duplication was hiding.Bug fixes
cell_area_cm2was frozen at import time.scripts/JV/jv_core.pyandscripts/Dark_JV/dark_jv_core.pycaptured the device area into a module constant when the module was first imported. The area scales Jsc — and therefore PCE — linearly, so correcting it in the config did nothing until the whole application was restarted. It is now read when the analysis runs, andparse_*/process_*accept an explicitarea_cm2for callers that want to pass one. A missing, zero, negative or unparseable value falls back to the documented0.04instead of producing an infinite conversion factor.The XRD/PL panels could never find a configured API key.
spectra/gui/tab_dashboard.pyandspectra/gui/tab_pl.pycounted one..too many and looked one directory above the project root. The same bug had already been fixed inspectra/core/report.py; these two copies were missed.Installing the package produced two empty namespaces.
[tool.setuptools] packageslisted onlyscriptsandspectra, excluding all twelve subpackages, so everyfrom scripts.JV.jv_core import ...failed after an install. Switched to discovery (15 packages) and declared the bundled ASTM G173-03 spectrum as package data.Deduplication
New
scripts/common/modules:app_config.py— the single reader/writer forphysisfera_config.json. Caches on mtime so an edit is picked up without a restart, resolves the frozen-build path to the config next to the executable rather than into the unpacked bundle, honoursPHYSISCORE_CONFIG, and writes atomically while preserving keys owned by other modules.origin.py—connect_to_origin, previously six near-identical copies. They differed only in log wording and a 30 s vs 60 s timeout, and each swallowed every exception from the minute-long wait loop with a bareexcept:— which catchesKeyboardInterrupt, so Ctrl-C during the wait was ignored.naming.py—natural_sort_keyand the sample display-name rules, duplicated between the light and dark J-V parsers. Both scan types of one device now provably get the same label.Performance
Both ALS baselines rebuilt their difference matrix in a format
spsolvehad to convert on every iteration. The operator is now hoisted out of the loop and built as CSC. This removes 32 of the 33 warnings the suite emitted; the last was a LabTalk\gbeing read as a Python escape.Tests
35 new tests covering config resolution, the cell-area plumbing and the naming rules.
The 55 pre-existing tests are unchanged and still pass. GUI modules can't be imported in a headless environment, so intra-project imports and cross-module attribute access were checked statically via AST instead — no dangling references.
Notes for review
spectranow imports fromscripts.common, which it did not before. Both ship in the same distribution, and one config reader seemed worth the new edge._legacy/carries the same kind of duplication but was left alone as explicitly archived code.CONFIG.mdandREADME.mdare updated to say so.