Skip to content

Write every file of a standalone run into one output folder - #129

Merged
timlichtenberg merged 15 commits into
mainfrom
tl/zalmoxis-output-dir
Nov 8, 2026
Merged

timlichtenberg merged 15 commits into
mainfrom
tl/zalmoxis-output-dir

Conversation

@timlichtenberg

Copy link
Copy Markdown
Member

Description

python -m zalmoxis now writes all its files into one output folder: the profiles, the summary, the plots, zalmoxis.log and, at the DEBUG level, the 2 iteration profile files. The folder is the new [Output] key output_dir (an existing, writable folder), or else output/ of the Zalmoxis root, which the run creates on a fresh checkout. Without debug_profile_dir, the command-line run puts the DEBUG dump into the same folder; a library or PROTEUS caller that sets neither key writes no file, as with #128.

  • load_zalmoxis_config and validate_config refuse an output_dir that is not a string or path, is empty, or is not an existing, writable folder.
  • plot_PT_with_phases adds the mass to its file name (mantle_PT_profile<mass>.pdf), so a batch run no longer overwrites one file per mass.
  • The CLI log is a file handler in write mode at INFO; if the file cannot be opened, the log goes to stderr with a warning that names the file.
  • The grid runner tools/grids/run_grid.py does not use output_dir; usage.md says where it writes and which files stay outside the output folder (the EOS caches under data/).
  • Docs: configuration, usage, first run and installation pages; citations on the edited pages use footnotes.

The branch merges main after #128 (merge commit d1ff740); the conflicts were in input/default.toml, config.py, __main__.py, AGENTS.md, configuration.md, usage.md and test_main_cli.py. The main test that mocked logging.basicConfig for the log path is replaced by tests on the real log file (path, overwrite, level, format) in tests/test_output_dir.py.

No related issue.

Validation of changes

  • Nightly at eb8c418, all 8 jobs green (main job: 2686 passed, 5 skipped, total coverage 96.94 %): https://github.com/FormingWorlds/Zalmoxis/actions/runs/42466604775. The last commit (9ed4e7c) changes only docs/How-to/usage.md.
  • On the branch source at eb8c418 (macOS arm64, Python 3.12): pytest tests/test_output_dir.py tests/test_output.py tests/test_main_cli.py tests/test_debug_profile_output.py tests/test_config_validators_extra.py gives 100 passed. Patch coverage of the changed source lines from these files: 28 of 30 (diff-cover); the 2 other lines are 1 plot call in each of plot_phase_vs_radius.py and plot_profiles.py.
  • The DEBUG dump of a command-line run: tests/test_main_cli.py::TestZalmoxisCli::test_main_passes_its_output_folder_for_the_debug_dump checks that the CLI passes its output folder as debug_profile_dir (unless the config names one), and tests/test_debug_profile_output.py::test_debug_solve_writes_the_dump_into_the_given_folder checks that a DEBUG solve writes both profile files into that folder.
  • Docs: every citation on the edited pages is a footnote.

Behaviour to know:

  • post_processing checks output_dir even when data output and plots are both off. With data output or plots on and no output_dir, it creates the default folder before the solve.
  • output_dir=None in a library dict is refused by validate_config but means the default folder in post_processing; one rule for both is a follow-up.

Lines by category (pr-breakdown 4a6fbd6 9ed4e7c):

Category Files Lines added / removed Size on disk (KiB) Compressed (KiB)
tests 3 +470 / -33 +18.0 +4.6
source 5 +73 / -24 +2.5 +0.8
docs text 5 +71 / -49 +5.9 +2.4
other 1 +1 / -0 +0.1 +0.0

Checklist

  • I have followed the contributing guidelines
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have checked that the tests still pass on my computer
  • I have updated the docs, as appropriate
  • I have added tests for these changes, as appropriate
  • I have checked that all dependencies have been updated, as required

With [Output] output_dir the profile, the summary, the profile plot, the mantle P-T plot (named with id_mass) and the CLI log go into that folder and nothing into <root>/output or the working directory; without it a library call keeps <root>/output. The key takes an existing folder; other types, an empty value and a missing folder raise ValueError.
post_processing, the profile plot, the mantle P-T plot and the log of python -m zalmoxis write into output_dir when the config names it, an existing folder (the validator refuses other types, an empty value and a missing folder). Without the key a library call keeps <root>/output and the CLI sets that folder. The CLI holds the log lines of the config load in memory until the folder is known. The mantle P-T plot carries id_mass in its file name, as the profiles do.
The buffered log lines of the config load reach <output_dir>/zalmoxis.log also when the load raises; then the folder is <root>/output, which the CLI creates on a fresh checkout so that the config error is not hidden.
An unwritable folder is refused; post_processing checks a given folder it gets from a dict; plots alone create the default folder; a refused config keeps its error when the log cannot be opened and logs that error; the log is overwritten, formatted and at INFO; the real loader of a default.toml with output_dir sends the log there. Names at the edges replace the generated names.
The folder check also refuses a folder without write permission, and post_processing applies it to a given output_dir; without one it creates <root>/output for the data and the plots alike. The CLI logs the error of a refused config, logs to stderr when the folder cannot take the log, and swaps the buffer for the log file without a gap. The docs name the folder rules (relative paths, no ~ expansion, writable) and the DEBUG profile files that stay in <root>/output.
…log fallback warning

A folder without search permission is refused like one without write permission; post_processing with data and plots off makes no folder; the CLI warns on stderr when zalmoxis.log cannot be opened. The logging fixtures close only the handlers they added.
… only when a file is written

The folder check takes write and search permission, which a new file needs. post_processing makes <root>/output only when it writes data or plots. The CLI warns when zalmoxis.log cannot be opened and the log goes to stderr.
Both the output folder and the DEBUG profile folder keys stay; each keeps its own check, and the command-line run sets both defaults.
…folder

Without debug_profile_dir, python -m zalmoxis sets it to output_dir, so a DEBUG run keeps every file of the run in one folder.
The configuration reference and the first-run tutorial cite each paper as Author (year) with a footnote that gives the authors, title, journal, volume, pages, year, DOI and SciX link. The PALEOS liquidus row cites Belonoshko et al. (2005) in Physical Review Letters and Fei et al. (2021) in Nature Communications, the papers that the PALEOS tables use.
…d the EOS caches write

The output folder holds the files of python -m zalmoxis. The grid runner writes into the folder of its grid file and still needs a valid output_dir in its base config when that config sets one; the EOS caches stay beside their tables and in data/EOS_PALEOS_API.
@timlichtenberg
timlichtenberg requested a review from a team as a code owner November 8, 2026 11:10
@timlichtenberg
timlichtenberg merged commit 49246c0 into main Nov 8, 2026
4 checks passed
@timlichtenberg
timlichtenberg deleted the tl/zalmoxis-output-dir branch November 8, 2026 21:04
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.

1 participant