Skip to content
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

alexsherstinsky
Copy link
Contributor

@alexsherstinsky alexsherstinsky commented Mar 16, 2022

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, different ParameterBuilder implementations interpret the results according to their own logic, often depending on whether or not the number of metric_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:

  • JIRA: GREAT-464/GREAT-498/GREAT-674

Definition of Done

Please delete options that are not relevant.

  • My code follows the Great Expectations style guide
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added unit tests where applicable and made sure that new and existing tests are passing.
  • I have run any local integration tests and made sure that nothing is broken.

Thank you for submitting!

Alex Sherstinsky added 2 commits March 15, 2022 17:55
…sherstinsky/rule_based_profiler_fix_bug_one_regex_get_parameters_result_error-2022_03_15-52
@netlify
Copy link

netlify bot commented Mar 16, 2022

✔️ 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

Copy link
Contributor

@Shinnnyshinshin Shinnnyshinshin left a 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()),
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Member

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)

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼

Copy link
Member

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?

Copy link
Contributor Author

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.

@alexsherstinsky alexsherstinsky merged commit 6a7dd66 into develop Mar 16, 2022
@alexsherstinsky alexsherstinsky deleted the bugfix/GREAT-464/GREAT-498/GREAT-674/alexsherstinsky/rule_based_profiler_fix_bug_one_regex_get_parameters_result_error-2022_03_15-52 branch March 16, 2022 02:57
metric_values = metric_values[:, 0]
if (
reduce_scalar_metric
and len(metric_values) == 1
Copy link
Member

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 (
Copy link
Member

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 ofMetricValues` 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

Copy link
Contributor Author

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()),
Copy link
Member

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(
Copy link
Member

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?

Copy link
Member

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

Copy link
Contributor Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants