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
[BUGFIX] Insure Proper Indexing of Metric Computation Results in ParameterBuilder #4426
Conversation
…sherstinsky/rule_based_profiler_fix_bug_one_regex_get_parameters_result_error-2022_03_15-52
✔️ Deploy Preview for niobium-lead-7998 ready! 🔨 Explore the source changes: d8b5ac0 🔍 Inspect the deploy log: https://app.netlify.com/sites/niobium-lead-7998/deploys/62313f354e176d0008f6c638 😎 Browse the preview: https://deploy-preview-4426--niobium-lead-7998.netlify.app |
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.
Looks wonderful sir @alexsherstinsky thank you so much for your help with this.
].metric_values | ||
if len(metric_value_kwargs) == 1 | ||
else attributed_resolved_metrics_map.values(), | ||
list(attributed_resolved_metrics_map.values()), |
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.
❤️
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.
This is a long method, it seems we can encapsulate much of what is happening here in MetricValues (have MetricValues responsible for itself rather than having ParameterBuilder manipulate it)
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.
@donaldheppner These types are placeholder ones, which we intended to replace as part of a MAINTENANCE task (I just created a JIRA item for it). Thanks.
metric_values = metric_values[:, 0] | ||
if ( | ||
reduce_scalar_metric | ||
and len(metric_values) == 1 |
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.
👍🏼
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.
I would rather handle a well defined metric values type than introduce these complicated if statements. As a future refactor, can we encapsulate this logic in the MetricValues class?
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.
@donaldheppner These types are placeholder ones, which led to needing this logic for certain ParameterBuilder
implementations. It was intended to be replaced as part of a MAINTENANCE task (I just created a JIRA item for it). Thanks.
metric_values = metric_values[:, 0] | ||
if ( | ||
reduce_scalar_metric | ||
and len(metric_values) == 1 |
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.
I would rather handle a well defined metric values type than introduce these complicated if statements. As a future refactor, can we encapsulate this logic in the MetricValues class?
and isinstance(metric_values[0], AttributedResolvedMetrics) | ||
and metric_values[0].metric_values.shape[1] == 1 | ||
): | ||
metric_values = metric_values[0].metric_values[:, 0] | ||
|
||
return ( |
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.
Can we change the return type of this method from Tuple(Any, dict)
to Tuple(MetricValues, MetricComputationDetails)? Also, should
MetricComputationDetailsbe an attribute of
MetricValues` so we can avoid the Tuple all together? Every time you return a Tuple, it's one more thing for the caller to worry about
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.
@donaldheppner This can be done as part of replacing placeholder types with full-fledged classes. This was intended all along to be accomplished as part of a MAINTENANCE task (I just created a JIRA item for it). Thanks.
].metric_values | ||
if len(metric_value_kwargs) == 1 | ||
else attributed_resolved_metrics_map.values(), | ||
list(attributed_resolved_metrics_map.values()), |
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.
This is a long method, it seems we can encapsulate much of what is happening here in MetricValues (have MetricValues responsible for itself rather than having ParameterBuilder manipulate it)
isinstance(metric_computation_result.metric_values, list) | ||
and len(metric_computation_result.metric_values) == 1 | ||
): | ||
raise ge_exceptions.ProfilerExecutionError( |
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.
When does this occur? Is there a way to make this code path unreachable with earlier checks?
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.
This is especially relevant since it is repeated across MANY parameter builders. Again, this could be great functionality to encapsulate in the MetricValues class
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.
When does this occur? Is there a way to make this code path unreachable with earlier checks?
@donaldheppner This never occurs (just did this check for defensive programming).
Scope
We return results from
get_metrics()
as list, even if the length of list is 1 (previous simplification introduced inconsistencies in the way results are interpreted). Now, differentParameterBuilder
implementations interpret the results according to their own logic, often depending on whether or not the number ofmetric_value_kwargs
is greater than 1.Please annotate your PR title to describe what the PR does, then give a brief bulleted description of your PR below. PR titles should begin with [BUGFIX], [FEATURE], [DOCS], or [MAINTENANCE]. If a new feature introduces breaking changes for the Great Expectations API or configuration files, please also add [BREAKING]. You can read about the tags in our contributor checklist.
Changes proposed in this pull request:
After submitting your PR, CI checks will run and @ge-cla-bot will check for your CLA signature.
For a PR with nontrivial changes, we review with both design-centric and code-centric lenses.
In a design review, we aim to ensure that the PR is consistent with our relationship to the open source community, with our software architecture and abstractions, and with our users' needs and expectations. That review often starts well before a PR, for example in github issues or slack, so please link to relevant conversations in notes below to help reviewers understand and approve your PR more quickly (e.g.
closes #123
).Previous Design Review notes:
Definition of Done
Please delete options that are not relevant.
Thank you for submitting!