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/data_context/data_context.py b/great_expectations/data_context/data_context.py
--- a/great_expectations/data_context/data_context.py
+++ b/great_expectations/data_context/data_context.py
@@ -100,7 +100,7 @@
 from great_expectations.dataset import Dataset
 from great_expectations.datasource import LegacyDatasource
 from great_expectations.datasource.new_datasource import BaseDatasource, Datasource
-from great_expectations.exceptions import DataContextError
+from great_expectations.exceptions import DataContextError, InvalidKeyError
 from great_expectations.marshmallow__shade import ValidationError
 from great_expectations.profile.basic_dataset_profiler import BasicDatasetProfiler
 from great_expectations.render.renderer.site_builder import SiteBuilder
@@ -2312,14 +2312,7 @@ def store_validation_result_metrics(
 
     def store_evaluation_parameters(self, validation_results, target_store_name=None):
         if not self._evaluation_parameter_dependencies_compiled:
-            # get the expectation suite if it exists, otherwise None
-            expectation_suite_name = validation_results.meta["expectation_suite_name"]
-            if expectation_suite_name in self.list_expectation_suite_names():
-                expectation_suite = self.get_expectation_suite(expectation_suite_name)
-            else:
-                expectation_suite = None
-
-            self._compile_evaluation_parameter_dependencies(expectation_suite)
+            self._compile_evaluation_parameter_dependencies()
 
         if target_store_name is None:
             target_store_name = self.evaluation_parameter_store_name
@@ -2348,17 +2341,15 @@ def validations_store_name(self):
     def validations_store(self):
         return self.stores[self.validations_store_name]
 
-    def _compile_evaluation_parameter_dependencies(self, expectation_suite):
+    def _compile_evaluation_parameter_dependencies(self):
         self._evaluation_parameter_dependencies = {}
+        # NOTE: Chetan - 20211118: This iteration is reverting the behavior performed here: https://github.com/great-expectations/great_expectations/pull/3377
+        # This revision was necessary due to breaking changes but will need to be brought back in a future ticket.
+        for key in self.expectations_store.list_keys():
+            expectation_suite = self.expectations_store.get(key)
+            if not expectation_suite:
+                continue
 
-        # only if we don't have an expectation suite do we do a key scan
-        if expectation_suite is None:
-            for key in self.expectations_store.list_keys():
-                expectation_suite = self.expectations_store.get(key)
-                if not expectation_suite:
-                    continue
-
-        if expectation_suite:
             dependencies = expectation_suite.get_evaluation_parameter_dependencies()
             if len(dependencies) > 0:
                 nested_update(self._evaluation_parameter_dependencies, dependencies)


Test patch:
diff --git a/tests/data_context/store/test_store_backends.py b/tests/data_context/store/test_store_backends.py
--- a/tests/data_context/store/test_store_backends.py
+++ b/tests/data_context/store/test_store_backends.py
@@ -645,82 +645,87 @@ def test_TupleS3StoreBackend_with_prefix():
     )
 
 
-@mock_s3
-def test_tuple_s3_store_backend_expectation_suite_and_validation_operator_share_prefix(
-    validation_operators_data_context: DataContext,
-    parameterized_expectation_suite: ExpectationSuite,
-):
-    """
-    What does this test test and why?
-
-    In cases where an s3 store is used with the same prefix for both validations
-    and expectations, the list_keys() operation picks up files ending in .json
-    from both validations and expectations stores.
-
-    To avoid this issue, the expectation suite configuration, if available, is used
-    to locate the specific key for the suite in place of calling list_keys().
-
-    NOTE: It is an issue with _all stores_ when the result of list_keys() contain paths
-    with a period (.) and are passed to ExpectationSuiteIdentifier.from_tuple() method,
-    as happens in the DataContext.store_evaluation_parameters() method. The best fix is
-    to choose a different delimiter for generating expectation suite identifiers (or
-    perhaps escape the period in path names).
-
-    For now, the fix is to avoid the call to list_keys() in
-    DataContext.store_evaluation_parameters() if the expectation suite is known (from config).
-    This approach should also improve performance.
-
-    This test confirms the fix for GitHub issue #3054.
-    """
-    bucket = "leakybucket"
-    prefix = "this_is_a_test_prefix"
-
-    # create a bucket in Moto's mock AWS environment
-    conn = boto3.resource("s3", region_name="us-east-1")
-    conn.create_bucket(Bucket=bucket)
-
-    # replace store backends with the mock, both with the same prefix (per issue #3054)
-    validation_operators_data_context.validations_store._store_backend = (
-        TupleS3StoreBackend(
-            bucket=bucket,
-            prefix=prefix,
-        )
-    )
-    validation_operators_data_context.expectations_store._store_backend = (
-        TupleS3StoreBackend(
-            bucket=bucket,
-            prefix=prefix,
-        )
-    )
-
-    validation_operators_data_context.save_expectation_suite(
-        parameterized_expectation_suite, "param_suite"
-    )
-
-    # ensure the suite is in the context
-    assert validation_operators_data_context.expectations_store.has_key(
-        ExpectationSuiteIdentifier("param_suite")
-    )
-
-    res = validation_operators_data_context.run_validation_operator(
-        "store_val_res_and_extract_eval_params",
-        assets_to_validate=[
-            (
-                validation_operators_data_context.build_batch_kwargs(
-                    "my_datasource", "subdir_reader", "f1"
-                ),
-                "param_suite",
-            )
-        ],
-        evaluation_parameters={
-            "urn:great_expectations:validations:source_patient_data.default:expect_table_row_count_to_equal.result"
-            ".observed_value": 3
-        },
-    )
-
-    assert (
-        res["success"] is True
-    ), "No exception thrown, validation operators ran successfully"
+# NOTE: Chetan - 20211118: I am commenting out this test as it was introduced in: https://github.com/great-expectations/great_expectations/pull/3377
+# We've decided to roll back these changes for the time being since they introduce some unintendend consequences.
+#
+# This is a gentle reminder to future contributors to please re-enable this test when revisiting the matter.
+
+# @mock_s3
+# def test_tuple_s3_store_backend_expectation_suite_and_validation_operator_share_prefix(
+#     validation_operators_data_context: DataContext,
+#     parameterized_expectation_suite: ExpectationSuite,
+# ):
+#     """
+#     What does this test test and why?
+
+#     In cases where an s3 store is used with the same prefix for both validations
+#     and expectations, the list_keys() operation picks up files ending in .json
+#     from both validations and expectations stores.
+
+#     To avoid this issue, the expectation suite configuration, if available, is used
+#     to locate the specific key for the suite in place of calling list_keys().
+
+#     NOTE: It is an issue with _all stores_ when the result of list_keys() contain paths
+#     with a period (.) and are passed to ExpectationSuiteIdentifier.from_tuple() method,
+#     as happens in the DataContext.store_evaluation_parameters() method. The best fix is
+#     to choose a different delimiter for generating expectation suite identifiers (or
+#     perhaps escape the period in path names).
+
+#     For now, the fix is to avoid the call to list_keys() in
+#     DataContext.store_evaluation_parameters() if the expectation suite is known (from config).
+#     This approach should also improve performance.
+
+#     This test confirms the fix for GitHub issue #3054.
+#     """
+#     bucket = "leakybucket"
+#     prefix = "this_is_a_test_prefix"
+
+#     # create a bucket in Moto's mock AWS environment
+#     conn = boto3.resource("s3", region_name="us-east-1")
+#     conn.create_bucket(Bucket=bucket)
+
+#     # replace store backends with the mock, both with the same prefix (per issue #3054)
+#     validation_operators_data_context.validations_store._store_backend = (
+#         TupleS3StoreBackend(
+#             bucket=bucket,
+#             prefix=prefix,
+#         )
+#     )
+#     validation_operators_data_context.expectations_store._store_backend = (
+#         TupleS3StoreBackend(
+#             bucket=bucket,
+#             prefix=prefix,
+#         )
+#     )
+
+#     validation_operators_data_context.save_expectation_suite(
+#         parameterized_expectation_suite, "param_suite"
+#     )
+
+#     # ensure the suite is in the context
+#     assert validation_operators_data_context.expectations_store.has_key(
+#         ExpectationSuiteIdentifier("param_suite")
+#     )
+
+#     res = validation_operators_data_context.run_validation_operator(
+#         "store_val_res_and_extract_eval_params",
+#         assets_to_validate=[
+#             (
+#                 validation_operators_data_context.build_batch_kwargs(
+#                     "my_datasource", "subdir_reader", "f1"
+#                 ),
+#                 "param_suite",
+#             )
+#         ],
+#         evaluation_parameters={
+#             "urn:great_expectations:validations:source_patient_data.default:expect_table_row_count_to_equal.result"
+#             ".observed_value": 3
+#         },
+#     )
+
+#     assert (
+#         res["success"] is True
+#     ), "No exception thrown, validation operators ran successfully"
 
 
 @mock_s3
diff --git a/tests/data_context/test_data_context.py b/tests/data_context/test_data_context.py
--- a/tests/data_context/test_data_context.py
+++ b/tests/data_context/test_data_context.py
@@ -221,14 +221,7 @@ def test_compile_evaluation_parameter_dependencies(
         data_context_parameterized_expectation_suite._evaluation_parameter_dependencies
         == {}
     )
-    expectation_suite = (
-        data_context_parameterized_expectation_suite.get_expectation_suite(
-            parameterized_expectation_suite_name
-        )
-    )
-    data_context_parameterized_expectation_suite._compile_evaluation_parameter_dependencies(
-        expectation_suite
-    )
+    data_context_parameterized_expectation_suite._compile_evaluation_parameter_dependencies()
     assert data_context_parameterized_expectation_suite._evaluation_parameter_dependencies == {
         "source_diabetes_data.default": [
             {