Skip to content

Adding error messags for ps costign when key does not exist#14

Merged
avdudchenko merged 3 commits into
mainfrom
dev
Apr 15, 2026
Merged

Adding error messags for ps costign when key does not exist#14
avdudchenko merged 3 commits into
mainfrom
dev

Conversation

@avdudchenko

Copy link
Copy Markdown
Owner

ps costing will now thorw errors liek ps_data_manager when a key fails to import.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds explicit failure behavior to the costing pipeline when requested costing key patterns cannot be discovered, aligning PsCostingManager behavior more closely with PsDataManager’s import-status checks.

Changes:

  • Track “unfound” costing key suffixes during PsCostingManager._discover_keys() and raise KeyError via a new _check_discovery_status() method.
  • Call _check_discovery_status() during PsCostingManager.build() so builds fail fast on misconfigured/misspelled key suffixes.
  • Add unit tests covering _check_discovery_status() and the new build-time failure behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/psPlotKit/data_manager/ps_costing.py Adds missing-key tracking, a discovery-status check with nearest-key suggestions, and enforces failure in build() when patterns don’t match any available keys.
src/psPlotKit/data_manager/tests/test_ps_costing.py Adds tests validating no-raise when keys are found and KeyError when requested suffixes cannot be discovered (including via build()).

Comment on lines +1269 to +1271
"""Only unfound keys should appear in the error — found ones should not."""
pkg = PsCostingPackage()
g = PsCostingGroup("Membrane")

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 7928d04. The test now captures the exc_info and adds assert "capital_cost" not in str(exc_info.value) to enforce that found keys are absent from the error message, matching the docstring.

Comment thread src/psPlotKit/data_manager/ps_costing.py
@avdudchenko avdudchenko merged commit 596dda7 into main Apr 15, 2026
17 checks passed
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.

3 participants