Skip to content

Print messages#6

Open
TimBartholomew wants to merge 4 commits into
avdudchenko:mainfrom
TimBartholomew:print_messages
Open

Print messages#6
TimBartholomew wants to merge 4 commits into
avdudchenko:mainfrom
TimBartholomew:print_messages

Conversation

@TimBartholomew

Copy link
Copy Markdown
Contributor

Summary

This PR removes repeated console spam during batch PHREEQC runs and fixes the underlying Alkalinity MW handling that was triggering it.

The repeated messages came from two places:

  • an unconditional database load print on every phreeqcWTapi instantiation
  • repeated MW recomputation for Alkalinity, even when the metadata already had a valid stored MW for the intentional formula Ca0.5(CO3)0.5

That second path could fail to parse the formula and fall back noisily, which is why repeated PW_TEA runs produced the typo-heavy warning many times.

What changed

  • Replaced the unconditional Loading database file: ... console print with debug logging, so default behavior is quiet.
  • Removed the normal-operation stdout warning for MW fallback and routed that path through debug logging instead.
  • Updated master-species MW handling so check_formula_consistent() reuses the existing stored MW when:
    • the formula has not changed, and
    • the metadata already contains an MW
  • Added explicit handling for the known Alkalinity formula Ca0.5(CO3)0.5 with MW 50.05 during metadata-derived MW calculation.
  • Preserved direct Alkalinity input support.
  • Kept the existing CaHCO3 helper behavior that emits both inorganic carbon and alkalinity when requested.
  • Avoided reintroducing the earlier direct-Alkalinity behavior that duplicated carbon master-species lines and perturbed pH.

Behavior impact

This is not only output suppression.

It also fixes the underlying Alkalinity MW/formula path so normal direct Alkalinity usage no longer attempts an unnecessary recomputation and no longer falls into the noisy fallback path.

Public behavior is otherwise intended to remain stable:

  • no input API changes
  • no required verbosity flag changes for callers
  • no intentional command log structure changes

Tests

Added regression coverage for:

  • direct Alkalinity input still generating only the alkalinity line
  • direct Alkalinity input reusing metadata MW without console output
  • repeated phreeqcWTapi(database="phreeqc.dat") instantiation staying quiet by default
  • existing CaHCO3 helper behavior still generating both carbon and alkalinity lines

Validated locally with:

  • pytest src/phreeqcinwt/tests/test_solution_build.py -k "direct_alkalinity or repeated_instantiation or cahco3"
  • runtime repeated-instantiation check with direct Alkalinity input and no console output
  • python -m black --check src/phreeqcinwt/core/data_base_utils.py src/phreeqcinwt/core/utility_functions.py src/phreeqcinwt/tests/test_solution_build.py

@avdudchenko

Copy link
Copy Markdown
Owner

This looks good. @TimBartholomew Please updated with latest main change and re-run tests. Not sure why its not letting me auto push latest changes into this pr...

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