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/data_assistant/data_assistant.py b/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
--- a/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
+++ b/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
@@ -378,7 +378,7 @@ def build_partition_parameter_builder(
     def __init__(
         self,
         name: str,
-        validator: Validator,
+        validator: Optional[Validator],
     ) -> None:
         """
         DataAssistant subclasses guide "RuleBasedProfiler" to contain Rule configurations to embody profiling behaviors,
@@ -395,9 +395,12 @@ def __init__(
 
         self._validator = validator
 
-        self._batches = self._validator.batches
-
-        self._data_context = self._validator.data_context
+        if validator is None:
+            self._data_context = None
+            self._batches = None
+        else:
+            self._data_context = self._validator.data_context
+            self._batches = self._validator.batches
 
         variables: Optional[Dict[str, Any]] = self.get_variables() or {}
         self._profiler = RuleBasedProfiler(
diff --git a/great_expectations/rule_based_profiler/data_assistant/data_assistant_runner.py b/great_expectations/rule_based_profiler/data_assistant/data_assistant_runner.py
--- a/great_expectations/rule_based_profiler/data_assistant/data_assistant_runner.py
+++ b/great_expectations/rule_based_profiler/data_assistant/data_assistant_runner.py
@@ -4,6 +4,8 @@
 from typing import Any, Callable, Dict, List, Optional, Type, Union
 
 from great_expectations.core.batch import BatchRequestBase
+from great_expectations.core.config_peer import ConfigOutputModes, ConfigOutputModeType
+from great_expectations.data_context.types.base import BaseYamlConfig
 from great_expectations.rule_based_profiler.data_assistant import DataAssistant
 from great_expectations.rule_based_profiler.helpers.util import (
     get_validator_with_expectation_suite,
@@ -102,41 +104,95 @@ def __init__(
         self._data_assistant_cls = data_assistant_cls
         self._data_context = data_context
 
+    def _build_data_assistant(
+        self,
+        batch_request: Optional[Union[BatchRequestBase, dict]] = None,
+    ) -> DataAssistant:
+        """
+        batch_request: Explicit batch_request used to supply data at runtime
+        """
+        data_assistant_name: str = self._data_assistant_cls.data_assistant_type
+
+        data_assistant: DataAssistant
+
+        if batch_request is None:
+            data_assistant = self._data_assistant_cls(
+                name=data_assistant_name,
+                validator=None,
+            )
+        else:
+            validator: Validator = get_validator_with_expectation_suite(
+                data_context=self._data_context,
+                batch_list=None,
+                batch_request=batch_request,
+                expectation_suite=None,
+                expectation_suite_name=None,
+                component_name=data_assistant_name,
+                persist=False,
+            )
+            data_assistant = self._data_assistant_cls(
+                name=data_assistant_name,
+                validator=validator,
+            )
+
+        return data_assistant
+
+    def get_profiler_config(
+        self,
+        mode: ConfigOutputModeType = ConfigOutputModes.JSON_DICT,
+    ) -> Union[BaseYamlConfig, dict, str]:
+        """
+        batch_request: Explicit batch_request used to supply data at runtime
+        mode: One of "ConfigOutputModes" Enum typed values (corresponding string typed values are also supported)
+        """
+        return self._build_data_assistant(batch_request=None).profiler.get_config(
+            mode=mode
+        )
+
     @augment_arguments(**_build_enum_to_default_kwargs_map())
     def run(
         self,
-        variables: Optional[Dict[str, Any]] = None,
-        rules: Optional[Dict[str, Dict[str, Any]]] = None,
         batch_request: Optional[Union[BatchRequestBase, dict]] = None,
         **kwargs: dict,
     ) -> DataAssistantResult:
         """
-        variables: attribute name/value pairs, commonly-used in Builder objects, to modify using "runtime_environment"
-        rules: name/(configuration-dictionary) to modify using "runtime_environment"
-        kwargs: additional/override directives supplied at runtime
+        batch_request: Explicit batch_request used to supply data at runtime
+        kwargs: additional/override directives supplied at runtime (using "runtime_environment")
             "kwargs" directives structure:
             {
-                "include_column_names": ["column_a", "column_b", "column_c", ...],
-                "exclude_column_names": ["column_d", "column_e", "column_f", "column_g", ...],
-                ...
+                "DomainBuilder" parameters:
+                include_column_names=["column_a", "column_b", "column_c", ...],
+                exclude_column_names=["column_d", "column_e", "column_f", "column_g", ...],
+                max_unexpected_values=0,
+                max_unexpected_ratio=None,
+                min_max_unexpected_values_proportion=9.75e-1,
+                ... Other "DomainBuilder" parameters ...
+                "variables" settings for "Rule" configurations:
+                numeric_columns_rule={
+                    "round_decimals": 12,
+                    "false_positive_rate": 0.1,
+                    "random_seed": 43792,
+                },
+                datetime_columns_rule={
+                    "truncate_values": {
+                        "lower_bound": 0,
+                        "upper_bound": 4481049600,  # Friday, January 1, 2112 0:00:00
+                    },
+                    "round_decimals": 0,
+                },
+                categorical_columns_rule={
+                    "false_positive_rate": 0.1,
+                    "round_decimals": 4,
+                },
+                ... "variables" settings for other "Rule" configurations ...
             }
         Implementation makes best effort at assigning directives to appropriate "MetricDomainTypes" member.
 
         Returns:
             DataAssistantResult: The result object for the DataAssistant
         """
-        data_assistant_name: str = self._data_assistant_cls.data_assistant_type
-        validator: Validator = get_validator_with_expectation_suite(
-            data_context=self._data_context,
-            batch_request=batch_request,
-            expectation_suite=None,
-            expectation_suite_name=None,
-            component_name=data_assistant_name,
-            persist=False,
-        )
-        data_assistant: DataAssistant = self._data_assistant_cls(
-            name=data_assistant_name,
-            validator=validator,
+        data_assistant: DataAssistant = self._build_data_assistant(
+            batch_request=batch_request
         )
         directives: dict = deep_filter_properties_iterable(
             properties=kwargs,
@@ -149,8 +205,6 @@ def run(
             RuntimeEnvironmentDomainTypeDirectives
         ] = build_domain_type_directives(**directives)
         data_assistant_result: DataAssistantResult = data_assistant.run(
-            variables=variables,
-            rules=rules,
             variables_directives_list=variables_directives_list,
             domain_type_directives_list=domain_type_directives_list,
         )
diff --git a/great_expectations/rule_based_profiler/helpers/runtime_environment.py b/great_expectations/rule_based_profiler/helpers/runtime_environment.py
--- a/great_expectations/rule_based_profiler/helpers/runtime_environment.py
+++ b/great_expectations/rule_based_profiler/helpers/runtime_environment.py
@@ -22,7 +22,13 @@ class RuntimeEnvironmentColumnDomainTypeDirectivesKeys(Enum):  # isort:skip
     EXCLUDE_COLUMN_NAME_SUFFIXES = "exclude_column_name_suffixes"
     INCLUDE_SEMANTIC_TYPES = "include_semantic_types"
     EXCLUDE_SEMANTIC_TYPES = "exclude_semantic_types"
+    ALLOWED_SEMANTIC_TYPES_PASSTHROUGH = "allowed_semantic_types_passthrough"
     CARDINALITY_LIMIT_MODE = "cardinality_limit_mode"
+    MAX_UNIQUE_VALUES = "max_unique_values"
+    MAX_PROPORTION_UNIQUE = "max_proportion_unique"
+    MAX_UNEXPECTED_VALUES = "max_unexpected_values"
+    MAX_UNEXPECTED_RATIO = "max_unexpected_ratio"
+    MIN_MAX_UNEXPECTED_VALUES_PROPORTION = "min_max_unexpected_values_proportion"
 
 
 class RuntimeEnvironmentColumnPairDomainTypeDirectivesKeys(Enum):  # isort:skip


Test patch:
diff --git a/tests/integration/profiling/rule_based_profiler/test_profiler_user_workflows.py b/tests/integration/profiling/rule_based_profiler/test_profiler_user_workflows.py
--- a/tests/integration/profiling/rule_based_profiler/test_profiler_user_workflows.py
+++ b/tests/integration/profiling/rule_based_profiler/test_profiler_user_workflows.py
@@ -62,6 +62,7 @@ def alice_validator(alice_columnar_table_single_batch_context) -> Validator:
 
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
@@ -87,6 +88,7 @@ def bobby_validator(
 
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
@@ -117,6 +119,7 @@ def bobster_validator(
 
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
@@ -144,6 +147,7 @@ def quentin_validator(
 
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
@@ -1114,6 +1118,7 @@ def test_bobby_expect_column_values_to_be_between_auto_yes_default_profiler_conf
 
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
@@ -1360,6 +1365,7 @@ def test_bobby_expect_column_values_to_be_between_auto_yes_default_profiler_conf
 
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
diff --git a/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant.py b/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant.py
--- a/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant.py
+++ b/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant.py
@@ -144,6 +144,7 @@ def run_onboarding_data_assistant_result_jupyter_notebook_with_new_cell(
     explicit_instantiation_code: str = """
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
diff --git a/tests/rule_based_profiler/data_assistant/test_volume_data_assistant.py b/tests/rule_based_profiler/data_assistant/test_volume_data_assistant.py
--- a/tests/rule_based_profiler/data_assistant/test_volume_data_assistant.py
+++ b/tests/rule_based_profiler/data_assistant/test_volume_data_assistant.py
@@ -2155,6 +2155,7 @@ def quentin_explicit_instantiation_result_actual_time(
 
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
@@ -2191,6 +2192,7 @@ def quentin_explicit_instantiation_result_frozen_time(
 
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,
@@ -2307,6 +2309,7 @@ def run_volume_data_assistant_result_jupyter_notebook_with_new_cell(
     explicit_instantiation_code: str = """
     validator: Validator = get_validator_with_expectation_suite(
         data_context=context,
+        batch_list=None,
         batch_request=batch_request,
         expectation_suite_name=None,
         expectation_suite=None,