We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Use cleaner solution for non-truncating division in python 2
Prefer `from __future__ import division` to `1.*x/y`

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `great_expectations/rule_based_profiler/rule/rule.py`
Content:
```
1 import copy
2 import json
3 from typing import Any, Callable, Dict, List, Optional, Union
4 
5 from great_expectations.core.batch import Batch, BatchRequestBase
6 from great_expectations.core.util import (
7     convert_to_json_serializable,
8     determine_progress_bar_method_by_environment,
9 )
10 from great_expectations.rule_based_profiler.config.base import (
11     domainBuilderConfigSchema,
12     expectationConfigurationBuilderConfigSchema,
13     parameterBuilderConfigSchema,
14 )
15 from great_expectations.rule_based_profiler.domain import Domain
16 from great_expectations.rule_based_profiler.domain_builder import DomainBuilder
17 from great_expectations.rule_based_profiler.expectation_configuration_builder import (
18     ExpectationConfigurationBuilder,
19 )
20 from great_expectations.rule_based_profiler.helpers.configuration_reconciliation import (
21     DEFAULT_RECONCILATION_DIRECTIVES,
22     ReconciliationDirectives,
23     reconcile_rule_variables,
24 )
25 from great_expectations.rule_based_profiler.helpers.util import (
26     convert_variables_to_dict,
27 )
28 from great_expectations.rule_based_profiler.parameter_builder import ParameterBuilder
29 from great_expectations.rule_based_profiler.parameter_container import (
30     ParameterContainer,
31     build_parameter_container_for_variables,
32 )
33 from great_expectations.rule_based_profiler.rule_state import RuleState
34 from great_expectations.types import SerializableDictDot
35 from great_expectations.util import (
36     deep_filter_properties_iterable,
37     measure_execution_time,
38 )
39 
40 
41 class Rule(SerializableDictDot):
42     def __init__(
43         self,
44         name: str,
45         variables: Optional[Union[ParameterContainer, Dict[str, Any]]] = None,
46         domain_builder: Optional[DomainBuilder] = None,
47         parameter_builders: Optional[List[ParameterBuilder]] = None,
48         expectation_configuration_builders: Optional[
49             List[ExpectationConfigurationBuilder]
50         ] = None,
51     ) -> None:
52         """
53         Sets Rule name, variables, domain builder, parameters builders, configuration builders, and other instance data.
54 
55         Args:
56             name: A string representing the name of the ProfilerRule
57             variables: Any variables to be substituted within the rules
58             domain_builder: A Domain Builder object used to build rule data domain
59             parameter_builders: A Parameter Builder list used to configure necessary rule evaluation parameters
60             expectation_configuration_builders: A list of Expectation Configuration Builders
61         """
62         self._name = name
63 
64         if variables is None:
65             variables = {}
66 
67         # Convert variables argument to ParameterContainer
68         _variables: ParameterContainer
69         if isinstance(variables, ParameterContainer):
70             _variables = variables
71         else:
72             _variables: ParameterContainer = build_parameter_container_for_variables(
73                 variables_configs=variables
74             )
75 
76         self.variables = _variables
77 
78         self._domain_builder = domain_builder
79         self._parameter_builders = parameter_builders
80         self._expectation_configuration_builders = expectation_configuration_builders
81 
82         self._execution_time = None
83 
84     @measure_execution_time(
85         execution_time_holder_object_reference_name="rule_state",
86         execution_time_property_name="rule_execution_time",
87         pretty_print=False,
88     )
89     def run(
90         self,
91         variables: Optional[ParameterContainer] = None,
92         batch_list: Optional[List[Batch]] = None,
93         batch_request: Optional[Union[BatchRequestBase, dict]] = None,
94         recompute_existing_parameter_values: bool = False,
95         reconciliation_directives: ReconciliationDirectives = DEFAULT_RECONCILATION_DIRECTIVES,
96         rule_state: Optional[RuleState] = None,
97     ) -> RuleState:
98         """
99         Builds a list of Expectation Configurations, returning a single Expectation Configuration entry for every
100         ConfigurationBuilder available based on the instantiation.
101 
102         Args:
103             variables: Attribute name/value pairs, commonly-used in Builder objects
104             batch_list: Explicit list of Batch objects to supply data at runtime
105             batch_request: Explicit batch_request used to supply data at runtime
106             recompute_existing_parameter_values: If "True", recompute value if "fully_qualified_parameter_name" exists
107             reconciliation_directives: directives for how each rule component should be overwritten
108             rule_state: holds "Rule" execution state and responds to "execution_time_property_name" ("execution_time")
109 
110         Returns:
111             RuleState representing effect of executing Rule
112         """
113         variables = build_parameter_container_for_variables(
114             variables_configs=reconcile_rule_variables(
115                 variables=self.variables,
116                 variables_config=convert_variables_to_dict(variables=variables),
117                 reconciliation_strategy=reconciliation_directives.variables,
118             )
119         )
120 
121         if rule_state is None:
122             rule_state = RuleState()
123 
124         domains: List[Domain] = self._get_rule_domains(
125             variables=variables,
126             batch_list=batch_list,
127             batch_request=batch_request,
128             rule_state=rule_state,
129         )
130 
131         rule_state.rule = self
132         rule_state.variables = variables
133         rule_state.domains = domains
134 
135         rule_state.reset_parameter_containers()
136 
137         pbar_method: Callable = determine_progress_bar_method_by_environment()
138 
139         domain: Domain
140         for domain in pbar_method(
141             domains,
142             desc="Profiling Dataset:",
143             position=1,
144             leave=False,
145             bar_format="{desc:25}{percentage:3.0f}%|{bar}{r_bar}",
146         ):
147             rule_state.initialize_parameter_container_for_domain(domain=domain)
148 
149             parameter_builders: List[ParameterBuilder] = self.parameter_builders or []
150             parameter_builder: ParameterBuilder
151             for parameter_builder in parameter_builders:
152                 parameter_builder.build_parameters(
153                     domain=domain,
154                     variables=variables,
155                     parameters=rule_state.parameters,
156                     parameter_computation_impl=None,
157                     batch_list=batch_list,
158                     batch_request=batch_request,
159                     recompute_existing_parameter_values=recompute_existing_parameter_values,
160                 )
161 
162             expectation_configuration_builders: List[
163                 ExpectationConfigurationBuilder
164             ] = (self.expectation_configuration_builders or [])
165 
166             expectation_configuration_builder: ExpectationConfigurationBuilder
167 
168             for expectation_configuration_builder in expectation_configuration_builders:
169                 expectation_configuration_builder.resolve_validation_dependencies(
170                     domain=domain,
171                     variables=variables,
172                     parameters=rule_state.parameters,
173                     batch_list=batch_list,
174                     batch_request=batch_request,
175                     recompute_existing_parameter_values=recompute_existing_parameter_values,
176                 )
177 
178         return rule_state
179 
180     @property
181     def name(self) -> str:
182         return self._name
183 
184     @name.setter
185     def name(self, value: str) -> None:
186         self._name = value
187 
188     @property
189     def variables(self) -> Optional[ParameterContainer]:
190         # Returning a copy of the "self._variables" state variable in order to prevent write-before-read hazard.
191         return copy.deepcopy(self._variables)
192 
193     @variables.setter
194     def variables(self, value: Optional[ParameterContainer]) -> None:
195         self._variables = value
196 
197     @property
198     def domain_builder(self) -> Optional[DomainBuilder]:
199         return self._domain_builder
200 
201     @property
202     def parameter_builders(self) -> Optional[List[ParameterBuilder]]:
203         return self._parameter_builders
204 
205     @property
206     def expectation_configuration_builders(
207         self,
208     ) -> Optional[List[ExpectationConfigurationBuilder]]:
209         return self._expectation_configuration_builders
210 
211     @property
212     def execution_time(self) -> Optional[float]:  # Execution time (in seconds).
213         """
214         Property that holds "execution_time" of this "Rule" (in seconds).
215         """
216         return self._execution_time
217 
218     def to_dict(self) -> dict:
219         parameter_builder_configs: Optional[List[dict]] = None
220         parameter_builders: Optional[
221             Dict[str, ParameterBuilder]
222         ] = self._get_parameter_builders_as_dict()
223         parameter_builder: ParameterBuilder
224         if parameter_builders is not None:
225             # Roundtrip through schema validation to add/or restore any missing fields.
226             parameter_builder_configs = [
227                 parameterBuilderConfigSchema.load(parameter_builder.to_dict()).to_dict()
228                 for parameter_builder in parameter_builders.values()
229             ]
230 
231         expectation_configuration_builder_configs: Optional[List[dict]] = None
232         expectation_configuration_builders: Optional[
233             Dict[str, ExpectationConfigurationBuilder]
234         ] = self._get_expectation_configuration_builders_as_dict()
235         expectation_configuration_builder: ExpectationConfigurationBuilder
236         if expectation_configuration_builders is not None:
237             # Roundtrip through schema validation to add/or restore any missing fields.
238             expectation_configuration_builder_configs = [
239                 expectationConfigurationBuilderConfigSchema.load(
240                     expectation_configuration_builder.to_dict()
241                 ).to_dict()
242                 for expectation_configuration_builder in expectation_configuration_builders.values()
243             ]
244 
245         return {
246             # Roundtrip through schema validation to add/or restore any missing fields.
247             "domain_builder": domainBuilderConfigSchema.load(
248                 self.domain_builder.to_dict()
249             ).to_dict(),
250             "parameter_builders": parameter_builder_configs,
251             "expectation_configuration_builders": expectation_configuration_builder_configs,
252         }
253 
254     def to_json_dict(self) -> dict:
255         """
256         # TODO: <Alex>2/4/2022</Alex>
257         This implementation of "SerializableDictDot.to_json_dict() occurs frequently and should ideally serve as the
258         reference implementation in the "SerializableDictDot" class itself.  However, the circular import dependencies,
259         due to the location of the "great_expectations/types/__init__.py" and "great_expectations/core/util.py" modules
260         make this refactoring infeasible at the present time.
261         """
262         dict_obj: dict = self.to_dict()
263         variables_dict: Optional[Dict[str, Any]] = convert_variables_to_dict(
264             variables=self.variables
265         )
266         dict_obj["variables"] = variables_dict
267         serializeable_dict: dict = convert_to_json_serializable(data=dict_obj)
268         return serializeable_dict
269 
270     def __repr__(self) -> str:
271         """
272         # TODO: <Alex>2/4/2022</Alex>
273         This implementation of a custom "__repr__()" occurs frequently and should ideally serve as the reference
274         implementation in the "SerializableDictDot" class.  However, the circular import dependencies, due to the
275         location of the "great_expectations/types/__init__.py" and "great_expectations/core/util.py" modules make this
276         refactoring infeasible at the present time.
277         """
278         json_dict: dict = self.to_json_dict()
279         deep_filter_properties_iterable(
280             properties=json_dict,
281             inplace=True,
282         )
283         return json.dumps(json_dict, indent=2)
284 
285     def __str__(self) -> str:
286         """
287         # TODO: <Alex>2/4/2022</Alex>
288         This implementation of a custom "__str__()" occurs frequently and should ideally serve as the reference
289         implementation in the "SerializableDictDot" class.  However, the circular import dependencies, due to the
290         location of the "great_expectations/types/__init__.py" and "great_expectations/core/util.py" modules make this
291         refactoring infeasible at the present time.
292         """
293         return self.__repr__()
294 
295     def _get_parameter_builders_as_dict(self) -> Dict[str, ParameterBuilder]:
296         parameter_builders: List[ParameterBuilder] = self.parameter_builders
297         if parameter_builders is None:
298             parameter_builders = []
299 
300         parameter_builder: ParameterBuilder
301         return {
302             parameter_builder.name: parameter_builder
303             for parameter_builder in parameter_builders
304         }
305 
306     def _get_expectation_configuration_builders_as_dict(
307         self,
308     ) -> Dict[str, ExpectationConfigurationBuilder]:
309         expectation_configuration_builders: List[
310             ExpectationConfigurationBuilder
311         ] = self.expectation_configuration_builders
312         if expectation_configuration_builders is None:
313             expectation_configuration_builders = []
314 
315         expectation_configuration_builder: ExpectationConfigurationBuilder
316         return {
317             expectation_configuration_builder.expectation_type: expectation_configuration_builder
318             for expectation_configuration_builder in expectation_configuration_builders
319         }
320 
321     # noinspection PyUnusedLocal
322     @measure_execution_time(
323         execution_time_holder_object_reference_name="rule_state",
324         execution_time_property_name="rule_domain_builder_execution_time",
325         pretty_print=False,
326     )
327     def _get_rule_domains(
328         self,
329         variables: Optional[ParameterContainer] = None,
330         batch_list: Optional[List[Batch]] = None,
331         batch_request: Optional[Union[BatchRequestBase, dict]] = None,
332         rule_state: Optional[RuleState] = None,
333     ) -> List[Domain]:
334         domains: List[Domain] = (
335             []
336             if self.domain_builder is None
337             else self.domain_builder.get_domains(
338                 rule_name=self.name,
339                 variables=variables,
340                 batch_list=batch_list,
341                 batch_request=batch_request,
342             )
343         )
344         return domains
345
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/great_expectations/rule_based_profiler/rule/rule.py b/great_expectations/rule_based_profiler/rule/rule.py
--- a/great_expectations/rule_based_profiler/rule/rule.py
+++ b/great_expectations/rule_based_profiler/rule/rule.py
@@ -79,8 +79,6 @@
         self._parameter_builders = parameter_builders
         self._expectation_configuration_builders = expectation_configuration_builders
 
-        self._execution_time = None
-
     @measure_execution_time(
         execution_time_holder_object_reference_name="rule_state",
         execution_time_property_name="rule_execution_time",
@@ -208,13 +206,6 @@
     ) -> Optional[List[ExpectationConfigurationBuilder]]:
         return self._expectation_configuration_builders
 
-    @property
-    def execution_time(self) -> Optional[float]:  # Execution time (in seconds).
-        """
-        Property that holds "execution_time" of this "Rule" (in seconds).
-        """
-        return self._execution_time
-
     def to_dict(self) -> dict:
         parameter_builder_configs: Optional[List[dict]] = None
         parameter_builders: Optional[

{"golden_diff": "diff --git a/great_expectations/rule_based_profiler/rule/rule.py b/great_expectations/rule_based_profiler/rule/rule.py\n--- a/great_expectations/rule_based_profiler/rule/rule.py\n+++ b/great_expectations/rule_based_profiler/rule/rule.py\n@@ -79,8 +79,6 @@\n         self._parameter_builders = parameter_builders\n         self._expectation_configuration_builders = expectation_configuration_builders\n \n-        self._execution_time = None\n-\n     @measure_execution_time(\n         execution_time_holder_object_reference_name=\"rule_state\",\n         execution_time_property_name=\"rule_execution_time\",\n@@ -208,13 +206,6 @@\n     ) -> Optional[List[ExpectationConfigurationBuilder]]:\n         return self._expectation_configuration_builders\n \n-    @property\n-    def execution_time(self) -> Optional[float]:  # Execution time (in seconds).\n-        \"\"\"\n-        Property that holds \"execution_time\" of this \"Rule\" (in seconds).\n-        \"\"\"\n-        return self._execution_time\n-\n     def to_dict(self) -> dict:\n         parameter_builder_configs: Optional[List[dict]] = None\n         parameter_builders: Optional[\n", "issue": "Use cleaner solution for non-truncating division in python 2\nPrefer `from __future__ import division` to `1.*x/y`\n", "before_files": [{"content": "import copy\nimport json\nfrom typing import Any, Callable, Dict, List, Optional, Union\n\nfrom great_expectations.core.batch import Batch, BatchRequestBase\nfrom great_expectations.core.util import (\n    convert_to_json_serializable,\n    determine_progress_bar_method_by_environment,\n)\nfrom great_expectations.rule_based_profiler.config.base import (\n    domainBuilderConfigSchema,\n    expectationConfigurationBuilderConfigSchema,\n    parameterBuilderConfigSchema,\n)\nfrom great_expectations.rule_based_profiler.domain import Domain\nfrom great_expectations.rule_based_profiler.domain_builder import DomainBuilder\nfrom great_expectations.rule_based_profiler.expectation_configuration_builder import (\n    ExpectationConfigurationBuilder,\n)\nfrom great_expectations.rule_based_profiler.helpers.configuration_reconciliation import (\n    DEFAULT_RECONCILATION_DIRECTIVES,\n    ReconciliationDirectives,\n    reconcile_rule_variables,\n)\nfrom great_expectations.rule_based_profiler.helpers.util import (\n    convert_variables_to_dict,\n)\nfrom great_expectations.rule_based_profiler.parameter_builder import ParameterBuilder\nfrom great_expectations.rule_based_profiler.parameter_container import (\n    ParameterContainer,\n    build_parameter_container_for_variables,\n)\nfrom great_expectations.rule_based_profiler.rule_state import RuleState\nfrom great_expectations.types import SerializableDictDot\nfrom great_expectations.util import (\n    deep_filter_properties_iterable,\n    measure_execution_time,\n)\n\n\nclass Rule(SerializableDictDot):\n    def __init__(\n        self,\n        name: str,\n        variables: Optional[Union[ParameterContainer, Dict[str, Any]]] = None,\n        domain_builder: Optional[DomainBuilder] = None,\n        parameter_builders: Optional[List[ParameterBuilder]] = None,\n        expectation_configuration_builders: Optional[\n            List[ExpectationConfigurationBuilder]\n        ] = None,\n    ) -> None:\n        \"\"\"\n        Sets Rule name, variables, domain builder, parameters builders, configuration builders, and other instance data.\n\n        Args:\n            name: A string representing the name of the ProfilerRule\n            variables: Any variables to be substituted within the rules\n            domain_builder: A Domain Builder object used to build rule data domain\n            parameter_builders: A Parameter Builder list used to configure necessary rule evaluation parameters\n            expectation_configuration_builders: A list of Expectation Configuration Builders\n        \"\"\"\n        self._name = name\n\n        if variables is None:\n            variables = {}\n\n        # Convert variables argument to ParameterContainer\n        _variables: ParameterContainer\n        if isinstance(variables, ParameterContainer):\n            _variables = variables\n        else:\n            _variables: ParameterContainer = build_parameter_container_for_variables(\n                variables_configs=variables\n            )\n\n        self.variables = _variables\n\n        self._domain_builder = domain_builder\n        self._parameter_builders = parameter_builders\n        self._expectation_configuration_builders = expectation_configuration_builders\n\n        self._execution_time = None\n\n    @measure_execution_time(\n        execution_time_holder_object_reference_name=\"rule_state\",\n        execution_time_property_name=\"rule_execution_time\",\n        pretty_print=False,\n    )\n    def run(\n        self,\n        variables: Optional[ParameterContainer] = None,\n        batch_list: Optional[List[Batch]] = None,\n        batch_request: Optional[Union[BatchRequestBase, dict]] = None,\n        recompute_existing_parameter_values: bool = False,\n        reconciliation_directives: ReconciliationDirectives = DEFAULT_RECONCILATION_DIRECTIVES,\n        rule_state: Optional[RuleState] = None,\n    ) -> RuleState:\n        \"\"\"\n        Builds a list of Expectation Configurations, returning a single Expectation Configuration entry for every\n        ConfigurationBuilder available based on the instantiation.\n\n        Args:\n            variables: Attribute name/value pairs, commonly-used in Builder objects\n            batch_list: Explicit list of Batch objects to supply data at runtime\n            batch_request: Explicit batch_request used to supply data at runtime\n            recompute_existing_parameter_values: If \"True\", recompute value if \"fully_qualified_parameter_name\" exists\n            reconciliation_directives: directives for how each rule component should be overwritten\n            rule_state: holds \"Rule\" execution state and responds to \"execution_time_property_name\" (\"execution_time\")\n\n        Returns:\n            RuleState representing effect of executing Rule\n        \"\"\"\n        variables = build_parameter_container_for_variables(\n            variables_configs=reconcile_rule_variables(\n                variables=self.variables,\n                variables_config=convert_variables_to_dict(variables=variables),\n                reconciliation_strategy=reconciliation_directives.variables,\n            )\n        )\n\n        if rule_state is None:\n            rule_state = RuleState()\n\n        domains: List[Domain] = self._get_rule_domains(\n            variables=variables,\n            batch_list=batch_list,\n            batch_request=batch_request,\n            rule_state=rule_state,\n        )\n\n        rule_state.rule = self\n        rule_state.variables = variables\n        rule_state.domains = domains\n\n        rule_state.reset_parameter_containers()\n\n        pbar_method: Callable = determine_progress_bar_method_by_environment()\n\n        domain: Domain\n        for domain in pbar_method(\n            domains,\n            desc=\"Profiling Dataset:\",\n            position=1,\n            leave=False,\n            bar_format=\"{desc:25}{percentage:3.0f}%|{bar}{r_bar}\",\n        ):\n            rule_state.initialize_parameter_container_for_domain(domain=domain)\n\n            parameter_builders: List[ParameterBuilder] = self.parameter_builders or []\n            parameter_builder: ParameterBuilder\n            for parameter_builder in parameter_builders:\n                parameter_builder.build_parameters(\n                    domain=domain,\n                    variables=variables,\n                    parameters=rule_state.parameters,\n                    parameter_computation_impl=None,\n                    batch_list=batch_list,\n                    batch_request=batch_request,\n                    recompute_existing_parameter_values=recompute_existing_parameter_values,\n                )\n\n            expectation_configuration_builders: List[\n                ExpectationConfigurationBuilder\n            ] = (self.expectation_configuration_builders or [])\n\n            expectation_configuration_builder: ExpectationConfigurationBuilder\n\n            for expectation_configuration_builder in expectation_configuration_builders:\n                expectation_configuration_builder.resolve_validation_dependencies(\n                    domain=domain,\n                    variables=variables,\n                    parameters=rule_state.parameters,\n                    batch_list=batch_list,\n                    batch_request=batch_request,\n                    recompute_existing_parameter_values=recompute_existing_parameter_values,\n                )\n\n        return rule_state\n\n    @property\n    def name(self) -> str:\n        return self._name\n\n    @name.setter\n    def name(self, value: str) -> None:\n        self._name = value\n\n    @property\n    def variables(self) -> Optional[ParameterContainer]:\n        # Returning a copy of the \"self._variables\" state variable in order to prevent write-before-read hazard.\n        return copy.deepcopy(self._variables)\n\n    @variables.setter\n    def variables(self, value: Optional[ParameterContainer]) -> None:\n        self._variables = value\n\n    @property\n    def domain_builder(self) -> Optional[DomainBuilder]:\n        return self._domain_builder\n\n    @property\n    def parameter_builders(self) -> Optional[List[ParameterBuilder]]:\n        return self._parameter_builders\n\n    @property\n    def expectation_configuration_builders(\n        self,\n    ) -> Optional[List[ExpectationConfigurationBuilder]]:\n        return self._expectation_configuration_builders\n\n    @property\n    def execution_time(self) -> Optional[float]:  # Execution time (in seconds).\n        \"\"\"\n        Property that holds \"execution_time\" of this \"Rule\" (in seconds).\n        \"\"\"\n        return self._execution_time\n\n    def to_dict(self) -> dict:\n        parameter_builder_configs: Optional[List[dict]] = None\n        parameter_builders: Optional[\n            Dict[str, ParameterBuilder]\n        ] = self._get_parameter_builders_as_dict()\n        parameter_builder: ParameterBuilder\n        if parameter_builders is not None:\n            # Roundtrip through schema validation to add/or restore any missing fields.\n            parameter_builder_configs = [\n                parameterBuilderConfigSchema.load(parameter_builder.to_dict()).to_dict()\n                for parameter_builder in parameter_builders.values()\n            ]\n\n        expectation_configuration_builder_configs: Optional[List[dict]] = None\n        expectation_configuration_builders: Optional[\n            Dict[str, ExpectationConfigurationBuilder]\n        ] = self._get_expectation_configuration_builders_as_dict()\n        expectation_configuration_builder: ExpectationConfigurationBuilder\n        if expectation_configuration_builders is not None:\n            # Roundtrip through schema validation to add/or restore any missing fields.\n            expectation_configuration_builder_configs = [\n                expectationConfigurationBuilderConfigSchema.load(\n                    expectation_configuration_builder.to_dict()\n                ).to_dict()\n                for expectation_configuration_builder in expectation_configuration_builders.values()\n            ]\n\n        return {\n            # Roundtrip through schema validation to add/or restore any missing fields.\n            \"domain_builder\": domainBuilderConfigSchema.load(\n                self.domain_builder.to_dict()\n            ).to_dict(),\n            \"parameter_builders\": parameter_builder_configs,\n            \"expectation_configuration_builders\": expectation_configuration_builder_configs,\n        }\n\n    def to_json_dict(self) -> dict:\n        \"\"\"\n        # TODO: <Alex>2/4/2022</Alex>\n        This implementation of \"SerializableDictDot.to_json_dict() occurs frequently and should ideally serve as the\n        reference implementation in the \"SerializableDictDot\" class itself.  However, the circular import dependencies,\n        due to the location of the \"great_expectations/types/__init__.py\" and \"great_expectations/core/util.py\" modules\n        make this refactoring infeasible at the present time.\n        \"\"\"\n        dict_obj: dict = self.to_dict()\n        variables_dict: Optional[Dict[str, Any]] = convert_variables_to_dict(\n            variables=self.variables\n        )\n        dict_obj[\"variables\"] = variables_dict\n        serializeable_dict: dict = convert_to_json_serializable(data=dict_obj)\n        return serializeable_dict\n\n    def __repr__(self) -> str:\n        \"\"\"\n        # TODO: <Alex>2/4/2022</Alex>\n        This implementation of a custom \"__repr__()\" occurs frequently and should ideally serve as the reference\n        implementation in the \"SerializableDictDot\" class.  However, the circular import dependencies, due to the\n        location of the \"great_expectations/types/__init__.py\" and \"great_expectations/core/util.py\" modules make this\n        refactoring infeasible at the present time.\n        \"\"\"\n        json_dict: dict = self.to_json_dict()\n        deep_filter_properties_iterable(\n            properties=json_dict,\n            inplace=True,\n        )\n        return json.dumps(json_dict, indent=2)\n\n    def __str__(self) -> str:\n        \"\"\"\n        # TODO: <Alex>2/4/2022</Alex>\n        This implementation of a custom \"__str__()\" occurs frequently and should ideally serve as the reference\n        implementation in the \"SerializableDictDot\" class.  However, the circular import dependencies, due to the\n        location of the \"great_expectations/types/__init__.py\" and \"great_expectations/core/util.py\" modules make this\n        refactoring infeasible at the present time.\n        \"\"\"\n        return self.__repr__()\n\n    def _get_parameter_builders_as_dict(self) -> Dict[str, ParameterBuilder]:\n        parameter_builders: List[ParameterBuilder] = self.parameter_builders\n        if parameter_builders is None:\n            parameter_builders = []\n\n        parameter_builder: ParameterBuilder\n        return {\n            parameter_builder.name: parameter_builder\n            for parameter_builder in parameter_builders\n        }\n\n    def _get_expectation_configuration_builders_as_dict(\n        self,\n    ) -> Dict[str, ExpectationConfigurationBuilder]:\n        expectation_configuration_builders: List[\n            ExpectationConfigurationBuilder\n        ] = self.expectation_configuration_builders\n        if expectation_configuration_builders is None:\n            expectation_configuration_builders = []\n\n        expectation_configuration_builder: ExpectationConfigurationBuilder\n        return {\n            expectation_configuration_builder.expectation_type: expectation_configuration_builder\n            for expectation_configuration_builder in expectation_configuration_builders\n        }\n\n    # noinspection PyUnusedLocal\n    @measure_execution_time(\n        execution_time_holder_object_reference_name=\"rule_state\",\n        execution_time_property_name=\"rule_domain_builder_execution_time\",\n        pretty_print=False,\n    )\n    def _get_rule_domains(\n        self,\n        variables: Optional[ParameterContainer] = None,\n        batch_list: Optional[List[Batch]] = None,\n        batch_request: Optional[Union[BatchRequestBase, dict]] = None,\n        rule_state: Optional[RuleState] = None,\n    ) -> List[Domain]:\n        domains: List[Domain] = (\n            []\n            if self.domain_builder is None\n            else self.domain_builder.get_domains(\n                rule_name=self.name,\n                variables=variables,\n                batch_list=batch_list,\n                batch_request=batch_request,\n            )\n        )\n        return domains\n", "path": "great_expectations/rule_based_profiler/rule/rule.py"}], "after_files": [{"content": "import copy\nimport json\nfrom typing import Any, Callable, Dict, List, Optional, Union\n\nfrom great_expectations.core.batch import Batch, BatchRequestBase\nfrom great_expectations.core.util import (\n    convert_to_json_serializable,\n    determine_progress_bar_method_by_environment,\n)\nfrom great_expectations.rule_based_profiler.config.base import (\n    domainBuilderConfigSchema,\n    expectationConfigurationBuilderConfigSchema,\n    parameterBuilderConfigSchema,\n)\nfrom great_expectations.rule_based_profiler.domain import Domain\nfrom great_expectations.rule_based_profiler.domain_builder import DomainBuilder\nfrom great_expectations.rule_based_profiler.expectation_configuration_builder import (\n    ExpectationConfigurationBuilder,\n)\nfrom great_expectations.rule_based_profiler.helpers.configuration_reconciliation import (\n    DEFAULT_RECONCILATION_DIRECTIVES,\n    ReconciliationDirectives,\n    reconcile_rule_variables,\n)\nfrom great_expectations.rule_based_profiler.helpers.util import (\n    convert_variables_to_dict,\n)\nfrom great_expectations.rule_based_profiler.parameter_builder import ParameterBuilder\nfrom great_expectations.rule_based_profiler.parameter_container import (\n    ParameterContainer,\n    build_parameter_container_for_variables,\n)\nfrom great_expectations.rule_based_profiler.rule_state import RuleState\nfrom great_expectations.types import SerializableDictDot\nfrom great_expectations.util import (\n    deep_filter_properties_iterable,\n    measure_execution_time,\n)\n\n\nclass Rule(SerializableDictDot):\n    def __init__(\n        self,\n        name: str,\n        variables: Optional[Union[ParameterContainer, Dict[str, Any]]] = None,\n        domain_builder: Optional[DomainBuilder] = None,\n        parameter_builders: Optional[List[ParameterBuilder]] = None,\n        expectation_configuration_builders: Optional[\n            List[ExpectationConfigurationBuilder]\n        ] = None,\n    ) -> None:\n        \"\"\"\n        Sets Rule name, variables, domain builder, parameters builders, configuration builders, and other instance data.\n\n        Args:\n            name: A string representing the name of the ProfilerRule\n            variables: Any variables to be substituted within the rules\n            domain_builder: A Domain Builder object used to build rule data domain\n            parameter_builders: A Parameter Builder list used to configure necessary rule evaluation parameters\n            expectation_configuration_builders: A list of Expectation Configuration Builders\n        \"\"\"\n        self._name = name\n\n        if variables is None:\n            variables = {}\n\n        # Convert variables argument to ParameterContainer\n        _variables: ParameterContainer\n        if isinstance(variables, ParameterContainer):\n            _variables = variables\n        else:\n            _variables: ParameterContainer = build_parameter_container_for_variables(\n                variables_configs=variables\n            )\n\n        self.variables = _variables\n\n        self._domain_builder = domain_builder\n        self._parameter_builders = parameter_builders\n        self._expectation_configuration_builders = expectation_configuration_builders\n\n    @measure_execution_time(\n        execution_time_holder_object_reference_name=\"rule_state\",\n        execution_time_property_name=\"rule_execution_time\",\n        pretty_print=False,\n    )\n    def run(\n        self,\n        variables: Optional[ParameterContainer] = None,\n        batch_list: Optional[List[Batch]] = None,\n        batch_request: Optional[Union[BatchRequestBase, dict]] = None,\n        recompute_existing_parameter_values: bool = False,\n        reconciliation_directives: ReconciliationDirectives = DEFAULT_RECONCILATION_DIRECTIVES,\n        rule_state: Optional[RuleState] = None,\n    ) -> RuleState:\n        \"\"\"\n        Builds a list of Expectation Configurations, returning a single Expectation Configuration entry for every\n        ConfigurationBuilder available based on the instantiation.\n\n        Args:\n            variables: Attribute name/value pairs, commonly-used in Builder objects\n            batch_list: Explicit list of Batch objects to supply data at runtime\n            batch_request: Explicit batch_request used to supply data at runtime\n            recompute_existing_parameter_values: If \"True\", recompute value if \"fully_qualified_parameter_name\" exists\n            reconciliation_directives: directives for how each rule component should be overwritten\n            rule_state: holds \"Rule\" execution state and responds to \"execution_time_property_name\" (\"execution_time\")\n\n        Returns:\n            RuleState representing effect of executing Rule\n        \"\"\"\n        variables = build_parameter_container_for_variables(\n            variables_configs=reconcile_rule_variables(\n                variables=self.variables,\n                variables_config=convert_variables_to_dict(variables=variables),\n                reconciliation_strategy=reconciliation_directives.variables,\n            )\n        )\n\n        if rule_state is None:\n            rule_state = RuleState()\n\n        domains: List[Domain] = self._get_rule_domains(\n            variables=variables,\n            batch_list=batch_list,\n            batch_request=batch_request,\n            rule_state=rule_state,\n        )\n\n        rule_state.rule = self\n        rule_state.variables = variables\n        rule_state.domains = domains\n\n        rule_state.reset_parameter_containers()\n\n        pbar_method: Callable = determine_progress_bar_method_by_environment()\n\n        domain: Domain\n        for domain in pbar_method(\n            domains,\n            desc=\"Profiling Dataset:\",\n            position=1,\n            leave=False,\n            bar_format=\"{desc:25}{percentage:3.0f}%|{bar}{r_bar}\",\n        ):\n            rule_state.initialize_parameter_container_for_domain(domain=domain)\n\n            parameter_builders: List[ParameterBuilder] = self.parameter_builders or []\n            parameter_builder: ParameterBuilder\n            for parameter_builder in parameter_builders:\n                parameter_builder.build_parameters(\n                    domain=domain,\n                    variables=variables,\n                    parameters=rule_state.parameters,\n                    parameter_computation_impl=None,\n                    batch_list=batch_list,\n                    batch_request=batch_request,\n                    recompute_existing_parameter_values=recompute_existing_parameter_values,\n                )\n\n            expectation_configuration_builders: List[\n                ExpectationConfigurationBuilder\n            ] = (self.expectation_configuration_builders or [])\n\n            expectation_configuration_builder: ExpectationConfigurationBuilder\n\n            for expectation_configuration_builder in expectation_configuration_builders:\n                expectation_configuration_builder.resolve_validation_dependencies(\n                    domain=domain,\n                    variables=variables,\n                    parameters=rule_state.parameters,\n                    batch_list=batch_list,\n                    batch_request=batch_request,\n                    recompute_existing_parameter_values=recompute_existing_parameter_values,\n                )\n\n        return rule_state\n\n    @property\n    def name(self) -> str:\n        return self._name\n\n    @name.setter\n    def name(self, value: str) -> None:\n        self._name = value\n\n    @property\n    def variables(self) -> Optional[ParameterContainer]:\n        # Returning a copy of the \"self._variables\" state variable in order to prevent write-before-read hazard.\n        return copy.deepcopy(self._variables)\n\n    @variables.setter\n    def variables(self, value: Optional[ParameterContainer]) -> None:\n        self._variables = value\n\n    @property\n    def domain_builder(self) -> Optional[DomainBuilder]:\n        return self._domain_builder\n\n    @property\n    def parameter_builders(self) -> Optional[List[ParameterBuilder]]:\n        return self._parameter_builders\n\n    @property\n    def expectation_configuration_builders(\n        self,\n    ) -> Optional[List[ExpectationConfigurationBuilder]]:\n        return self._expectation_configuration_builders\n\n    def to_dict(self) -> dict:\n        parameter_builder_configs: Optional[List[dict]] = None\n        parameter_builders: Optional[\n            Dict[str, ParameterBuilder]\n        ] = self._get_parameter_builders_as_dict()\n        parameter_builder: ParameterBuilder\n        if parameter_builders is not None:\n            # Roundtrip through schema validation to add/or restore any missing fields.\n            parameter_builder_configs = [\n                parameterBuilderConfigSchema.load(parameter_builder.to_dict()).to_dict()\n                for parameter_builder in parameter_builders.values()\n            ]\n\n        expectation_configuration_builder_configs: Optional[List[dict]] = None\n        expectation_configuration_builders: Optional[\n            Dict[str, ExpectationConfigurationBuilder]\n        ] = self._get_expectation_configuration_builders_as_dict()\n        expectation_configuration_builder: ExpectationConfigurationBuilder\n        if expectation_configuration_builders is not None:\n            # Roundtrip through schema validation to add/or restore any missing fields.\n            expectation_configuration_builder_configs = [\n                expectationConfigurationBuilderConfigSchema.load(\n                    expectation_configuration_builder.to_dict()\n                ).to_dict()\n                for expectation_configuration_builder in expectation_configuration_builders.values()\n            ]\n\n        return {\n            # Roundtrip through schema validation to add/or restore any missing fields.\n            \"domain_builder\": domainBuilderConfigSchema.load(\n                self.domain_builder.to_dict()\n            ).to_dict(),\n            \"parameter_builders\": parameter_builder_configs,\n            \"expectation_configuration_builders\": expectation_configuration_builder_configs,\n        }\n\n    def to_json_dict(self) -> dict:\n        \"\"\"\n        # TODO: <Alex>2/4/2022</Alex>\n        This implementation of \"SerializableDictDot.to_json_dict() occurs frequently and should ideally serve as the\n        reference implementation in the \"SerializableDictDot\" class itself.  However, the circular import dependencies,\n        due to the location of the \"great_expectations/types/__init__.py\" and \"great_expectations/core/util.py\" modules\n        make this refactoring infeasible at the present time.\n        \"\"\"\n        dict_obj: dict = self.to_dict()\n        variables_dict: Optional[Dict[str, Any]] = convert_variables_to_dict(\n            variables=self.variables\n        )\n        dict_obj[\"variables\"] = variables_dict\n        serializeable_dict: dict = convert_to_json_serializable(data=dict_obj)\n        return serializeable_dict\n\n    def __repr__(self) -> str:\n        \"\"\"\n        # TODO: <Alex>2/4/2022</Alex>\n        This implementation of a custom \"__repr__()\" occurs frequently and should ideally serve as the reference\n        implementation in the \"SerializableDictDot\" class.  However, the circular import dependencies, due to the\n        location of the \"great_expectations/types/__init__.py\" and \"great_expectations/core/util.py\" modules make this\n        refactoring infeasible at the present time.\n        \"\"\"\n        json_dict: dict = self.to_json_dict()\n        deep_filter_properties_iterable(\n            properties=json_dict,\n            inplace=True,\n        )\n        return json.dumps(json_dict, indent=2)\n\n    def __str__(self) -> str:\n        \"\"\"\n        # TODO: <Alex>2/4/2022</Alex>\n        This implementation of a custom \"__str__()\" occurs frequently and should ideally serve as the reference\n        implementation in the \"SerializableDictDot\" class.  However, the circular import dependencies, due to the\n        location of the \"great_expectations/types/__init__.py\" and \"great_expectations/core/util.py\" modules make this\n        refactoring infeasible at the present time.\n        \"\"\"\n        return self.__repr__()\n\n    def _get_parameter_builders_as_dict(self) -> Dict[str, ParameterBuilder]:\n        parameter_builders: List[ParameterBuilder] = self.parameter_builders\n        if parameter_builders is None:\n            parameter_builders = []\n\n        parameter_builder: ParameterBuilder\n        return {\n            parameter_builder.name: parameter_builder\n            for parameter_builder in parameter_builders\n        }\n\n    def _get_expectation_configuration_builders_as_dict(\n        self,\n    ) -> Dict[str, ExpectationConfigurationBuilder]:\n        expectation_configuration_builders: List[\n            ExpectationConfigurationBuilder\n        ] = self.expectation_configuration_builders\n        if expectation_configuration_builders is None:\n            expectation_configuration_builders = []\n\n        expectation_configuration_builder: ExpectationConfigurationBuilder\n        return {\n            expectation_configuration_builder.expectation_type: expectation_configuration_builder\n            for expectation_configuration_builder in expectation_configuration_builders\n        }\n\n    # noinspection PyUnusedLocal\n    @measure_execution_time(\n        execution_time_holder_object_reference_name=\"rule_state\",\n        execution_time_property_name=\"rule_domain_builder_execution_time\",\n        pretty_print=False,\n    )\n    def _get_rule_domains(\n        self,\n        variables: Optional[ParameterContainer] = None,\n        batch_list: Optional[List[Batch]] = None,\n        batch_request: Optional[Union[BatchRequestBase, dict]] = None,\n        rule_state: Optional[RuleState] = None,\n    ) -> List[Domain]:\n        domains: List[Domain] = (\n            []\n            if self.domain_builder is None\n            else self.domain_builder.get_domains(\n                rule_name=self.name,\n                variables=variables,\n                batch_list=batch_list,\n                batch_request=batch_request,\n            )\n        )\n        return domains\n", "path": "great_expectations/rule_based_profiler/rule/rule.py"}]}