def test_deduplicate_evaluation_parameter_dependencies(): dependencies = { "profile": [ { "metric_kwargs_id": { "column=norm": ["expect_column_mean_to_be_between.result.observed_value"] } }, { "metric_kwargs_id": { "column=norm": [ "expect_column_stdev_to_be_between.result.observed_value" ] } }, ] } deduplicated = _deduplicate_evaluation_parameter_dependencies(dependencies) # For test, use set to ignore order deduplicated["profile"][0]["metric_kwargs_id"]["column=norm"] = set( deduplicated["profile"][0]["metric_kwargs_id"]["column=norm"]) assert { "profile": [{ "metric_kwargs_id": { "column=norm": { "expect_column_mean_to_be_between.result.observed_value", "expect_column_stdev_to_be_between.result.observed_value", } } }] } == deduplicated
def get_evaluation_parameter_dependencies(self): dependencies = {} for expectation in self.expectations: t = expectation.get_evaluation_parameter_dependencies() nested_update(dependencies, t) dependencies = _deduplicate_evaluation_parameter_dependencies(dependencies) return dependencies
def get_evaluation_parameter_dependencies(self): parsed_dependencies = dict() for key, value in self.kwargs.items(): if isinstance(value, dict) and "$PARAMETER" in value: param_string_dependencies = find_evaluation_parameter_dependencies( value["$PARAMETER"] ) nested_update(parsed_dependencies, param_string_dependencies) dependencies = dict() urns = parsed_dependencies.get("urns", []) for string_urn in urns: try: urn = ge_urn.parseString(string_urn) except ParserError: logger.warning( "Unable to parse great_expectations urn {}".format( value["$PARAMETER"] ) ) continue if not urn.get("metric_kwargs"): nested_update( dependencies, {urn["expectation_suite_name"]: [urn["metric_name"]]}, ) else: nested_update( dependencies, { urn["expectation_suite_name"]: [ { "metric_kwargs_id": { urn["metric_kwargs"]: [urn["metric_name"]] } } ] }, ) dependencies = _deduplicate_evaluation_parameter_dependencies(dependencies) return dependencies