Centralize algorithm parameters in grouped Settings with config-file loading#74
Merged
kripnerl merged 1 commit intoJun 11, 2026
Conversation
…loading Extract magic numbers (grid resolutions, solver tolerances, search heuristics, spline parameters, plotting and IO writer defaults) from equilibrium.py, equi_tools.py, surfaces.py, field_line_tracers.py, plotting.py, geqdsk.py and omas.py into pleque.config.Settings, organized into per-topic sections (grid, splines, critical_points, lcfs, field_line_tracing, flux_surfaces, plotting, io). Function arguments still override settings per call; settings are now read at use time instead of being captured at import time. Settings load from the first existing of: $PLEQUE_CONFIG_FILE, ./pleque.toml, the per-user config dir (%APPDATA%\pleque on Windows, $XDG_CONFIG_HOME/pleque elsewhere), or a [tool.pleque] table in the nearest pyproject.toml, with PLEQUE_-prefixed environment variables taking precedence over files. The winning file is recorded on the settings object (config_source, config_files_consulted) and reload_settings() re-reads the configuration at runtime. The old flat fields moved into sections: npsi_grid -> flux_surfaces.n_psi, psin0 -> flux_surfaces.psi_n_min, nr_grid/nz_grid -> lcfs.search_grid_nr/nz (the None sentinel is gone; defaults are 700/1200 directly). Also fix lcfs_field_line ignoring its vect_no and xp_shift arguments (they were hardcoded in the track_plasma_boundary call). Add tests for defaults, precedence, source tracking, env vars and reload; document the feature in docs/source/configuration.rst (kept in sync by a test) and README. pydantic-settings gains the toml extra for Python 3.10 support. https://claude.ai/code/session_01HRFoBXP3uhqR5cZuURzdhS
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.
Extract magic numbers (grid resolutions, solver tolerances, search
heuristics, spline parameters, plotting and IO writer defaults) from
equilibrium.py, equi_tools.py, surfaces.py, field_line_tracers.py,
plotting.py, geqdsk.py and omas.py into pleque.config.Settings,
organized into per-topic sections (grid, splines, critical_points,
lcfs, field_line_tracing, flux_surfaces, plotting, io). Function
arguments still override settings per call; settings are now read at
use time instead of being captured at import time.
Settings load from the first existing of: $PLEQUE_CONFIG_FILE,
./pleque.toml, the per-user config dir (%APPDATA%\pleque on Windows,
$XDG_CONFIG_HOME/pleque elsewhere), or a [tool.pleque] table in the
nearest pyproject.toml, with PLEQUE_-prefixed environment variables
taking precedence over files. The winning file is recorded on the
settings object (config_source, config_files_consulted) and
reload_settings() re-reads the configuration at runtime.
The old flat fields moved into sections: npsi_grid -> flux_surfaces.n_psi,
psin0 -> flux_surfaces.psi_n_min, nr_grid/nz_grid -> lcfs.search_grid_nr/nz
(the None sentinel is gone; defaults are 700/1200 directly).
Also fix lcfs_field_line ignoring its vect_no and xp_shift arguments
(they were hardcoded in the track_plasma_boundary call).
Add tests for defaults, precedence, source tracking, env vars and
reload; document the feature in docs/source/configuration.rst (kept in
sync by a test) and README. pydantic-settings gains the toml extra for
Python 3.10 support.
https://claude.ai/code/session_01HRFoBXP3uhqR5cZuURzdhS