Adding error messags for ps costign when key does not exist#14
Merged
Conversation
There was a problem hiding this comment.
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 raiseKeyErrorvia a new_check_discovery_status()method. - Call
_check_discovery_status()duringPsCostingManager.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") |
Contributor
There was a problem hiding this comment.
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.
Agent-Logs-Url: https://github.com/avdudchenko/psPlotKit/sessions/39e21845-14ed-44ca-8c67-8d4ff22302ad Co-authored-by: avdudchenko <33663878+avdudchenko@users.noreply.github.com>
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.
ps costing will now thorw errors liek ps_data_manager when a key fails to import.