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/core/usage_statistics/schemas.py b/great_expectations/core/usage_statistics/schemas.py
--- a/great_expectations/core/usage_statistics/schemas.py
+++ b/great_expectations/core/usage_statistics/schemas.py
@@ -553,7 +553,7 @@
         "init_payload": init_payload_schema,
         "run_validation_operator_payload": run_validation_operator_payload_schema,
         "anonymized_data_docs_site": anonymized_data_docs_site_schema,
-        "anonymized_batch_request_keys": anonymized_batch_request_schema,
+        "anonymized_batch_request": anonymized_batch_request_schema,
         "anonymized_batch": anonymized_batch_schema,
         "anonymized_expectation_suite": anonymized_expectation_suite_schema,
         "save_or_edit_expectation_suite_payload": save_or_edit_expectation_suite_payload_schema,
@@ -603,9 +603,7 @@
             "type": "object",
             "properties": {
                 "event": {"enum": ["data_context.get_batch_list"]},
-                "event_payload": {
-                    "$ref": "#/definitions/anonymized_batch_request_keys"
-                },
+                "event_payload": {"$ref": "#/definitions/anonymized_batch_request"},
             },
         },
         {
@@ -645,6 +643,7 @@
                     "enum": [
                         "data_context.build_data_docs",
                         "data_context.open_data_docs",
+                        "data_context.run_checkpoint",
                     ],
                 },
                 "event_payload": {"$ref": "#/definitions/empty_payload"},
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
@@ -3226,6 +3226,9 @@ def list_checkpoints(self) -> List[str]:
         else:
             return [x.configuration_key for x in self.checkpoint_store.list_keys()]
 
+    @usage_statistics_enabled_method(
+        event_name="data_context.run_checkpoint",
+    )
     def run_checkpoint(
         self,
         checkpoint_name: Optional[str] = None,


Test patch:
diff --git a/tests/cli/test_checkpoint.py b/tests/cli/test_checkpoint.py
--- a/tests/cli/test_checkpoint.py
+++ b/tests/cli/test_checkpoint.py
@@ -941,7 +941,7 @@ def test_checkpoint_run_on_checkpoint_with_not_found_suite_raises_error(
     stdout: str = result.stdout
     assert "expectation_suite suite_from_template_1 not found" in stdout
 
-    assert mock_emit.call_count == 3
+    assert mock_emit.call_count == 4
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -955,6 +955,13 @@ def test_checkpoint_run_on_checkpoint_with_not_found_suite_raises_error(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": False,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -1065,7 +1072,7 @@ def test_checkpoint_run_on_checkpoint_with_batch_load_problem_raises_error(
     # assert "No such file or directory" in stdout
     assert ("No such file or directory" in stdout) or ("does not exist" in stdout)
 
-    assert mock_emit.call_count == 5
+    assert mock_emit.call_count == 6
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -1108,6 +1115,13 @@ def test_checkpoint_run_on_checkpoint_with_batch_load_problem_raises_error(
                 "success": False,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": False,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -1200,7 +1214,7 @@ def test_checkpoint_run_on_checkpoint_with_empty_suite_list_raises_error(
         in stdout
     )
 
-    assert mock_emit.call_count == 3
+    assert mock_emit.call_count == 4
     assert mock_emit.call_args_list == [
         mock.call(
             {"event_payload": {}, "event": "data_context.__init__", "success": True}
@@ -1212,6 +1226,13 @@ def test_checkpoint_run_on_checkpoint_with_empty_suite_list_raises_error(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": False,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -1293,7 +1314,7 @@ def test_checkpoint_run_on_non_existent_validations(
         in stdout
     )
 
-    assert mock_emit.call_count == 3
+    assert mock_emit.call_count == 4
     assert mock_emit.call_args_list == [
         mock.call(
             {"event_payload": {}, "event": "data_context.__init__", "success": True}
@@ -1305,6 +1326,13 @@ def test_checkpoint_run_on_non_existent_validations(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": False,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -1406,7 +1434,7 @@ def test_checkpoint_run_happy_path_with_successful_validation_pandas(
         ]
     )
 
-    assert mock_emit.call_count == 7
+    assert mock_emit.call_count == 8
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -1466,6 +1494,13 @@ def test_checkpoint_run_happy_path_with_successful_validation_pandas(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": True,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -1568,7 +1603,7 @@ def test_checkpoint_run_happy_path_with_successful_validation_sql(
         ]
     )
 
-    assert mock_emit.call_count == 7
+    assert mock_emit.call_count == 8
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -1626,6 +1661,13 @@ def test_checkpoint_run_happy_path_with_successful_validation_sql(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": True,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -1732,7 +1774,7 @@ def test_checkpoint_run_happy_path_with_successful_validation_spark(
         ]
     )
 
-    assert mock_emit.call_count == 7
+    assert mock_emit.call_count == 8
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -1792,6 +1834,13 @@ def test_checkpoint_run_happy_path_with_successful_validation_spark(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": True,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -1896,7 +1945,7 @@ def test_checkpoint_run_happy_path_with_failed_validation_pandas(
     stdout: str = result.stdout
     assert "Validation failed!" in stdout
 
-    assert mock_emit.call_count == 7
+    assert mock_emit.call_count == 8
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -1956,6 +2005,13 @@ def test_checkpoint_run_happy_path_with_failed_validation_pandas(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": True,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -2048,7 +2104,7 @@ def test_checkpoint_run_happy_path_with_failed_validation_sql(
     stdout: str = result.stdout
     assert "Validation failed!" in stdout
 
-    assert mock_emit.call_count == 7
+    assert mock_emit.call_count == 8
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -2106,6 +2162,13 @@ def test_checkpoint_run_happy_path_with_failed_validation_sql(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": True,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -2203,7 +2266,7 @@ def test_checkpoint_run_happy_path_with_failed_validation_spark(
     stdout: str = result.stdout
     assert "Validation failed!" in stdout
 
-    assert mock_emit.call_count == 7
+    assert mock_emit.call_count == 8
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -2267,6 +2330,13 @@ def test_checkpoint_run_happy_path_with_failed_validation_spark(
                 "success": True,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": True,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -2371,7 +2441,7 @@ def test_checkpoint_run_happy_path_with_failed_validation_due_to_bad_data_pandas
     assert "Exception occurred while running Checkpoint." in stdout
     assert 'Error: The column "Name" in BatchData does not exist...' in stdout
 
-    assert mock_emit.call_count == 6
+    assert mock_emit.call_count == 7
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -2424,6 +2494,13 @@ def test_checkpoint_run_happy_path_with_failed_validation_due_to_bad_data_pandas
                 "success": False,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": False,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -2519,7 +2596,7 @@ def test_checkpoint_run_happy_path_with_failed_validation_due_to_bad_data_sql(
     assert "Exception occurred while running Checkpoint." in stdout
     assert 'Error: The column "Name" in BatchData does not exist...' in stdout
 
-    assert mock_emit.call_count == 6
+    assert mock_emit.call_count == 7
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -2570,6 +2647,13 @@ def test_checkpoint_run_happy_path_with_failed_validation_due_to_bad_data_sql(
                 "success": False,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": False,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
@@ -2676,7 +2760,7 @@ def test_checkpoint_run_happy_path_with_failed_validation_due_to_bad_data_spark(
     assert "Exception occurred while running Checkpoint." in stdout
     assert 'Error: The column "Name" in BatchData does not exist...' in stdout
 
-    assert mock_emit.call_count == 6
+    assert mock_emit.call_count == 7
 
     # noinspection PyUnresolvedReferences
     expected_events: List[unittest.mock._Call] = [
@@ -2733,6 +2817,13 @@ def test_checkpoint_run_happy_path_with_failed_validation_due_to_bad_data_spark(
                 "success": False,
             }
         ),
+        mock.call(
+            {
+                "event_payload": {},
+                "event": "data_context.run_checkpoint",
+                "success": False,
+            }
+        ),
         mock.call(
             {
                 "event": "cli.checkpoint.run.end",
diff --git a/tests/core/usage_statistics/test_usage_stats_schema.py b/tests/core/usage_statistics/test_usage_stats_schema.py
--- a/tests/core/usage_statistics/test_usage_stats_schema.py
+++ b/tests/core/usage_statistics/test_usage_stats_schema.py
@@ -58,6 +58,7 @@ def test_comprehensive_list_of_messages():
         "data_context.get_batch_list",
         "data_context.build_data_docs",
         "data_context.open_data_docs",
+        "data_context.run_checkpoint",
         "data_context.save_expectation_suite",
         "data_context.test_yaml_config",
         "datasource.sqlalchemy.connect",
@@ -235,6 +236,7 @@ def test_usage_stats_empty_payload_messages():
     usage_stats_records_messages = [
         "data_context.build_data_docs",
         "data_context.open_data_docs",
+        "data_context.run_checkpoint",
     ]
     for message_type in usage_stats_records_messages:
         for message in valid_usage_statistics_messages[message_type]:
diff --git a/tests/integration/usage_statistics/test_usage_statistics_messages.py b/tests/integration/usage_statistics/test_usage_statistics_messages.py
--- a/tests/integration/usage_statistics/test_usage_statistics_messages.py
+++ b/tests/integration/usage_statistics/test_usage_statistics_messages.py
@@ -540,6 +540,19 @@ def test_generate_messages_with_defaults():
             "x-forwarded-for": "00.000.00.000, 00.000.000.000",
         }
     ],
+    "data_context.run_checkpoint": [
+        {
+            "event_payload": {},
+            "event": "data_context.run_checkpoint",
+            "success": True,
+            "version": "1.0.0",
+            "event_time": "2020-06-25T16:08:28.070Z",
+            "data_context_id": "00000000-0000-0000-0000-000000000002",
+            "data_context_instance_id": "10000000-0000-0000-0000-000000000002",
+            "ge_version": "0.11.9.manual_testing",
+            "x-forwarded-for": "00.000.00.000, 00.000.000.000",
+        }
+    ],
     "data_context.save_expectation_suite": [
         {
             "event_payload": {