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

[MAINTENANCE] Improve types returned by DataAssistant interface methods #4859

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ def variables(self) -> Optional[Dict[str, Any]]:

@property
@abstractmethod
def rules(self) -> Optional[Dict[str, Dict[str, Any]]]:
def rules(self) -> Optional[List[Rule]]:
"""
Returns:
Optional custom "rules" configuration attribute name/(configuration-dictionary) (overrides) can be added.
Optional custom list of "Rule" objects (overrides) can be added by subclasses (return "None" if not needed).
"""
pass

Expand Down Expand Up @@ -360,9 +360,16 @@ def run_profiler_on_data(
expectation_suite_name: Optional[str] = None,
include_citation: bool = True,
) -> None:
if rules is None:
rules = []

rule: Rule
rules_configs: Optional[Dict[str, Dict[str, Any]]] = {
rule.name: rule.to_json_dict() for rule in rules
}
profiler.run(
variables=variables,
rules=rules,
rules=rules_configs,
batch_list=batch_list,
batch_request=batch_request,
force_batch_data=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
MetricMultiBatchParameterBuilder,
ParameterBuilder,
)
from great_expectations.rule_based_profiler.rule import Rule
from great_expectations.rule_based_profiler.types import (
DOMAIN_KWARGS_PARAMETER_FULLY_QUALIFIED_NAME,
)
Expand Down Expand Up @@ -74,5 +75,5 @@ def variables(self) -> Optional[Dict[str, Any]]:
return None

@property
def rules(self) -> Optional[Dict[str, Dict[str, Any]]]:
def rules(self) -> Optional[List[Rule]]:
return None
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,18 @@ def _build_parameters(
)

# Gather "metric_value_kwargs" for all candidate "strftime_format" strings.
fmt_string: str
format_string: str
match_strftime_metric_value_kwargs_list: List[dict] = []
match_strftime_metric_value_kwargs: dict
for fmt_string in candidate_strings:
for format_string in candidate_strings:
if self.metric_value_kwargs:
match_strftime_metric_value_kwargs = {
**self.metric_value_kwargs,
**{"strftime_format": fmt_string},
**{"strftime_format": format_string},
}
else:
match_strftime_metric_value_kwargs = {
"strftime_format": fmt_string,
"strftime_format": format_string,
}

match_strftime_metric_value_kwargs_list.append(
Expand Down Expand Up @@ -285,24 +285,24 @@ def _build_parameters(
)

# get best-matching datetime string that matches greater than threshold
best_fmt_string: str
best_format_string: str
best_ratio: float
(
best_fmt_string,
best_format_string,
best_ratio,
) = ParameterBuilder._get_best_candidate_above_threshold(
format_string_success_ratios, threshold
)
# dict of sorted datetime and ratios for all evaluated candidates
sorted_fmt_strings_and_ratios: dict = (
sorted_format_strings_and_ratios: dict = (
ParameterBuilder._get_sorted_candidates_and_ratios(
format_string_success_ratios
)
)
return (
best_fmt_string,
best_format_string,
{
"success_ratio": best_ratio,
"candidate_strings": sorted_fmt_strings_and_ratios,
"candidate_strings": sorted_format_strings_and_ratios,
},
)