Repository: great-expectations/great_expectations

Issue:
Use cleaner solution for non-truncating division in python 2
Prefer `from __future__ import division` to `1.*x/y`


Discussion:
Done inline during improve_partitions push.

Resolving patch:
diff --git a/great_expectations/rule_based_profiler/types/data_assistant_result/data_assistant_result.py b/great_expectations/rule_based_profiler/types/data_assistant_result/data_assistant_result.py
--- a/great_expectations/rule_based_profiler/types/data_assistant_result/data_assistant_result.py
+++ b/great_expectations/rule_based_profiler/types/data_assistant_result/data_assistant_result.py
@@ -1,8 +1,9 @@
 import copy
 import datetime
 import json
+import os
 from collections import defaultdict, namedtuple
-from dataclasses import dataclass
+from dataclasses import asdict, dataclass, field
 from typing import Any, Callable, Dict, KeysView, List, Optional, Set, Tuple, Union
 
 import altair as alt
@@ -56,6 +57,32 @@
 ColumnDataFrame = namedtuple("ColumnDataFrame", ["column", "df"])
 
 
+@dataclass
+class RuleStats(SerializableDictDot):
+    """
+    This class encapsulates basic "Rule" execution statistics.
+    """
+
+    domains_count_by_domain_type: Dict[MetricDomainTypes, int] = field(
+        default_factory=dict
+    )
+    domains_by_domain_type: Dict[MetricDomainTypes, List[dict]] = field(
+        default_factory=dict
+    )
+
+    def to_dict(self) -> dict:
+        """
+        Returns dictionary equivalent of this object.
+        """
+        return asdict(self)
+
+    def to_json_dict(self) -> dict:
+        """
+        Returns JSON dictionary equivalent of this object.
+        """
+        return convert_to_json_serializable(data=self.to_dict())
+
+
 @dataclass
 class DataAssistantResult(SerializableDictDot):
     """
@@ -183,19 +210,53 @@ def __repr__(self) -> str:
                 for key, value in json_dict.items()
                 if key in DataAssistantResult.IN_JUPYTER_NOTEBOOK_KEYS
             }
-            json_dict.update(
-                {
-                    "num_profiler_rules": len(self.profiler_config.rules),
-                    "num_domains": len(self.metrics_by_domain),
-                    "num_expectation_configurations": len(
-                        self.expectation_configurations
-                    ),
-                    "auto_generated_at": datetime.datetime.now(
-                        datetime.timezone.utc
-                    ).strftime("%Y%m%dT%H%M%S.%fZ"),
-                    "great_expectations_version": ge_version,
-                }
-            )
+            additional_info: dict = {
+                "num_profiler_rules": len(self.profiler_config.rules),
+                "num_expectation_configurations": len(self.expectation_configurations),
+                "auto_generated_at": datetime.datetime.now(
+                    datetime.timezone.utc
+                ).strftime("%Y%m%dT%H%M%S.%fZ"),
+                "great_expectations_version": ge_version,
+            }
+
+            verbose: Union[bool, str] = str(
+                os.getenv("GE_TROUBLESHOOTING", False)
+            ).lower()
+            if verbose != "true":
+                verbose = "false"
+
+            verbose = json.loads(verbose)
+
+            if verbose:
+                rule_name_to_rule_stats_map: Dict[str, RuleStats] = {}
+                rule_stats: RuleStats
+                domain: Domain
+                domain_as_json_dict: dict
+                rule_name: str
+                for domain in self.metrics_by_domain.keys():
+                    domain_as_json_dict = domain.to_json_dict()
+                    domain_as_json_dict.pop("domain_type")
+                    domain_as_json_dict.pop("rule_name")
+                    rule_name = domain.rule_name
+                    rule_stats = rule_name_to_rule_stats_map.get(rule_name)
+                    if rule_stats is None:
+                        rule_stats = RuleStats()
+                        rule_name_to_rule_stats_map[rule_name] = rule_stats
+                        rule_stats.domains_count_by_domain_type[domain.domain_type] = 1
+                        rule_stats.domains_by_domain_type[domain.domain_type] = [
+                            domain_as_json_dict
+                        ]
+                    else:
+                        rule_stats.domains_count_by_domain_type[domain.domain_type] += 1
+                        rule_stats.domains_by_domain_type[domain.domain_type].append(
+                            domain_as_json_dict
+                        )
+
+                    additional_info.update(
+                        convert_to_json_serializable(data=rule_name_to_rule_stats_map)
+                    )
+
+            json_dict.update(additional_info)
 
         return json.dumps(json_dict, indent=2)
 


Test patch: