-
Notifications
You must be signed in to change notification settings - Fork 1
[WIP] SAM-EM MCY Levelized Metrics Update #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
57e5674
f89d5d9
f00e42c
2872516
271be52
b67cf57
1780d64
225e846
2e9ddb6
ce44e3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import inspect | ||
| import numbers | ||
| import os.path | ||
| import sys | ||
| import unittest | ||
|
|
||
| from geophires_x.GeoPHIRESUtils import sig_figs | ||
|
|
@@ -123,6 +124,17 @@ def assertAlmostEqualWithinSigFigs(self, expected: float | int, actual: float | | |
| def _is_github_actions(self): | ||
| return 'CI' in os.environ or 'TOXPYTHON' in os.environ | ||
|
|
||
| def _handle_assert_logs_failure(self, ae: AssertionError): | ||
| if sys.version_info[:2] == (3, 8) and self._is_github_actions(): | ||
| # FIXME - see | ||
| # https://github.com/softwareengineerprogrammer/GEOPHIRES/actions/runs/19646240874/job/56262028512#step:5:344 | ||
| print( | ||
| f'WARNING: Skipping logs assertion in GitHub Actions ' | ||
| f'for Python {sys.version_info.major}.{sys.version_info.minor}' | ||
| ) | ||
| else: | ||
| raise ae | ||
|
|
||
| @staticmethod | ||
|
Comment on lines
+127
to
138
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore this change, it's incorrectly shown as belonging to this PR due to cherry-picking |
||
| def get_input_parameter(params: GeophiresInputParameters, param_name: str) -> float | str | None: | ||
| """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1137,14 +1137,3 @@ def _new_model(input_file: Path, additional_params: dict[str, Any] | None = None | |
| m.Calculate() | ||
|
|
||
| return m | ||
|
|
||
| def _handle_assert_logs_failure(self, ae: AssertionError): | ||
| if sys.version_info[:2] == (3, 8) and self._is_github_actions(): | ||
| # FIXME - see | ||
| # https://github.com/softwareengineerprogrammer/GEOPHIRES/actions/runs/19646240874/job/56262028512#step:5:344 | ||
| _log.warning( | ||
| f'WARNING: Skipping logs assertion in GitHub Actions ' | ||
| f'for Python {sys.version_info.major}.{sys.version_info.minor}' | ||
| ) | ||
| else: | ||
| raise ae | ||
|
Comment on lines
-1140
to
-1150
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore this change, it's incorrectly shown as belonging to this PR due to cherry-picking |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -323,34 +323,37 @@ def _del_metadata(r: GeophiresXResult) -> GeophiresXResult: | |
| del r.result['Simulation Metadata'] | ||
| return r | ||
|
|
||
| with self.assertLogs(level='INFO') as logs: | ||
| _del_metadata( | ||
| GeophiresXClient().get_geophires_result( | ||
| GeophiresInputParameters( | ||
| from_file_path=self._get_test_file_path('../examples/example5b.txt'), | ||
| params={ | ||
| 'Reservoir Output Profile': ','.join( | ||
| [str(it) for it in [30 * v for v in [*([10] * 7), 9, 8, 7]]] | ||
| ) | ||
| }, | ||
| try: | ||
| with self.assertLogs(level='INFO') as logs: | ||
| _del_metadata( | ||
| GeophiresXClient().get_geophires_result( | ||
| GeophiresInputParameters( | ||
| from_file_path=self._get_test_file_path('../examples/example5b.txt'), | ||
| params={ | ||
| 'Reservoir Output Profile': ','.join( | ||
| [str(it) for it in [30 * v for v in [*([10] * 7), 9, 8, 7]]] | ||
| ) | ||
| }, | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| self.assertHasLogRecordWithMessage( | ||
| logs, 'Reservoir temperature extrapolation result', treat_substring_match_as_match=True | ||
| ) | ||
| self.assertHasLogRecordWithMessage( | ||
| logs, 'Reservoir temperature extrapolation result', treat_substring_match_as_match=True | ||
| ) | ||
|
|
||
| self.assertHasLogRecordWithMessage( | ||
| logs, | ||
| # TODO make this less hard-coded | ||
| '[207.73, 177.48, 147.23, 116.97, 86.72, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0]', | ||
| treat_substring_match_as_match=True, | ||
| ) | ||
| self.assertHasLogRecordWithMessage( | ||
| logs, | ||
| # TODO make this less hard-coded | ||
| '[207.73, 177.48, 147.23, 116.97, 86.72, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, 80.0, ' | ||
| '80.0, 80.0]', | ||
| treat_substring_match_as_match=True, | ||
| ) | ||
| except AssertionError as ae: | ||
| self._handle_assert_logs_failure(ae) | ||
|
Comment on lines
-326
to
+359
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore this change, it's incorrectly shown as belonging to this PR due to cherry-picking |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ def test_assertAlmostEqualWithinPercentage_bad_arguments(self): | |
|
|
||
| self.assertIn(str(msg_type_error), '(you may have meant to pass percent=10)') | ||
|
|
||
| with self.assertLogs(level='INFO') as logs: | ||
| with self.assertLogs('tests.base_test_case', level='INFO') as logs: | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore this change, it's incorrectly shown as belonging to this PR due to cherry-picking |
||
| with self.assertRaises(AssertionError): | ||
| self.assertAlmostEqualWithinPercentage([1, 2, 3], [1.1, 2.2, 3.3], percent=10.5) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this change, it's incorrectly shown as belonging to this PR due to cherry-picking