Repository: great-expectations/great_expectations
Pull request #7095 (2023-02-09 19:06:48)

[MAINTENANCE] Rename experimental `get_batch_request` to `build_batch_request`
Changes proposed in this pull request:
- GREAT-1493
- Change method name from `get_batch_request` to `build_batch_request`

### Definition of Done
- [X] My code follows the Great Expectations [style guide](https://docs.greatexpectations.io/docs/contributing/style_guides/code_style)
- [X] I have performed a [self-review](https://docs.greatexpectations.io/docs/contributing/contributing_checklist) of my own code
- [X] I have commented my code, particularly in hard-to-understand areas
- [X] I have made corresponding changes to the documentation
- [X] I have added [unit tests](https://docs.greatexpectations.io/docs/contributing/contributing_test#writing-unit-and-integration-tests) where applicable and made sure that new and existing tests are passing.
- [X] I have run any local integration tests and made sure that nothing is broken.

netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *niobium-lead-7998* processing.


|  Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 75118fd1dba3c25a06038387e27bb103d5f4b08d |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/niobium-lead-7998/deploys/63e5444aff5d70000812162c |
codesee-maps[bot]: <details>
<summary><b>👇 <a href="https://app.codesee.io/r/reviews?pr=7095&src=https%3A%2F%2Fgithub.com%2Fgreat-expectations%2Fgreat_expectations">Click on the image</a> for a new way to code review</b>
</summary>

  - Make big changes easier — review code in small groups of related files
  - Know where to start — see the whole change at a glance
  - Take a code tour — explore the change with an interactive tour
  - Make comments and review — all fully sync’ed with github

    [Try it now!](https://app.codesee.io/r/reviews?pr=7095&src=https%3A%2F%2Fgithub.com%2Fgreat-expectations%2Fgreat_expectations)
</details>

[![Review these changes using an interactive CodeSee Map](https://s3.us-east-2.amazonaws.com/maps.codesee.io/images/github/great-expectations/great_expectations/7095/e53bece1/75118fd1dba3c25a06038387e27bb103d5f4b08d.svg)](https://app.codesee.io/r/reviews?pr=7095&src=https%3A%2F%2Fgithub.com%2Fgreat-expectations%2Fgreat_expectations)

#### Legend
![CodeSee Map Legend](https://app.codesee.io/Legend_v2.png)

Patch:
diff --git a/great_expectations/experimental/datasources/file_path_data_asset.py b/great_expectations/experimental/datasources/file_path_data_asset.py
index 0256d945b..2b7206cc1 100644
--- a/great_expectations/experimental/datasources/file_path_data_asset.py
+++ b/great_expectations/experimental/datasources/file_path_data_asset.py
@@ -71,7 +71,7 @@ class _FilePathDataAsset(DataAsset):
         idx: int
         return {idx: None for idx in self._all_group_names}
 
-    def get_batch_request(
+    def build_batch_request(
         self, options: Optional[BatchRequestOptions] = None
     ) -> BatchRequest:
         if options:
@@ -85,7 +85,7 @@ class _FilePathDataAsset(DataAsset):
                         f"not a string: {value}"
                     )
 
-        return super().get_batch_request(options)
+        return super().build_batch_request(options)
 
     def test_connection(self) -> None:
         """Test the connection for the DataAsset.
diff --git a/great_expectations/experimental/datasources/filesystem_data_asset.py b/great_expectations/experimental/datasources/filesystem_data_asset.py
index cc5a1487c..9d53520b4 100644
--- a/great_expectations/experimental/datasources/filesystem_data_asset.py
+++ b/great_expectations/experimental/datasources/filesystem_data_asset.py
@@ -132,7 +132,7 @@ to use as its "include" directive for Filesystem style DataAsset processing."""
         idx: int
         return {idx: None for idx in self._all_group_names}
 
-    def get_batch_request(
+    def build_batch_request(
         self, options: Optional[BatchRequestOptions] = None
     ) -> BatchRequest:
         if options:
@@ -145,7 +145,7 @@ to use as its "include" directive for Filesystem style DataAsset processing."""
                         f"All regex matching options must be strings. The value of '{option}' is "
                         f"not a string: {value}"
                     )
-        return super().get_batch_request(options)
+        return super().build_batch_request(options)
 
     def get_batch_list_from_batch_request(
         self, batch_request: BatchRequest
diff --git a/great_expectations/experimental/datasources/interfaces.py b/great_expectations/experimental/datasources/interfaces.py
index 76069248c..111bde863 100644
--- a/great_expectations/experimental/datasources/interfaces.py
+++ b/great_expectations/experimental/datasources/interfaces.py
@@ -170,10 +170,10 @@ class DataAsset(ExperimentalBaseModel):
     def batch_request_options_template(
         self,
     ) -> BatchRequestOptions:
-        """A BatchRequestOptions template for get_batch_request.
+        """A BatchRequestOptions template for build_batch_request.
 
         Returns:
-            A BatchRequestOptions dictionary with the correct shape that get_batch_request
+            A BatchRequestOptions dictionary with the correct shape that build_batch_request
             will understand. All the option values are defaulted to None.
         """
         raise NotImplementedError
@@ -185,7 +185,7 @@ class DataAsset(ExperimentalBaseModel):
 
     # End Abstract Methods
 
-    def get_batch_request(
+    def build_batch_request(
         self, options: Optional[BatchRequestOptions] = None
     ) -> BatchRequest:
         """A batch request that can be used to obtain batches for this DataAsset.
@@ -401,7 +401,7 @@ class Datasource(
 
         Args:
             batch_request: A batch request for this asset. Usually obtained by calling
-                get_batch_request on the asset.
+                build_batch_request on the asset.
 
         Returns:
             A list of batches that match the options specified in the batch request.
diff --git a/great_expectations/experimental/datasources/sql_datasource.py b/great_expectations/experimental/datasources/sql_datasource.py
index bbfd634d4..7b663cef2 100644
--- a/great_expectations/experimental/datasources/sql_datasource.py
+++ b/great_expectations/experimental/datasources/sql_datasource.py
@@ -191,10 +191,10 @@ class _SQLAsset(DataAsset, Generic[_ColumnSplitterT]):
     def batch_request_options_template(
         self,
     ) -> BatchRequestOptions:
-        """A BatchRequestOptions template for get_batch_request.
+        """A BatchRequestOptions template for build_batch_request.
 
         Returns:
-            A BatchRequestOptions dictionary with the correct shape that get_batch_request
+            A BatchRequestOptions dictionary with the correct shape that build_batch_request
             will understand. All the option values are defaulted to None.
         """
         template: BatchRequestOptions = {}
@@ -278,7 +278,7 @@ class _SQLAsset(DataAsset, Generic[_ColumnSplitterT]):
 
         Args:
             batch_request: A batch request for this asset. Usually obtained by calling
-                get_batch_request on the asset.
+                build_batch_request on the asset.
 
         Returns:
             A list of batches that match the options specified in the batch request.


Test patch:
diff --git a/tests/experimental/datasources/integration/conftest.py b/tests/experimental/datasources/integration/conftest.py
index 8e045c9bb..1c88459dd 100644
--- a/tests/experimental/datasources/integration/conftest.py
+++ b/tests/experimental/datasources/integration/conftest.py
@@ -32,7 +32,7 @@ def pandas_data(
         regex=r"yellow_tripdata_sample_(?P<year>\d{4})-(?P<month>\d{2})\.csv",
         order_by=["year", "month"],
     )
-    batch_request = asset.get_batch_request({"year": "2019", "month": "01"})
+    batch_request = asset.build_batch_request({"year": "2019", "month": "01"})
     return context, pandas_ds, asset, batch_request
 
 
@@ -68,7 +68,7 @@ def sql_data(
         .add_year_and_month_splitter(column_name="pickup_datetime")
         .add_sorters(["year", "month"])
     )
-    batch_request = asset.get_batch_request({"year": 2019, "month": 1})
+    batch_request = asset.build_batch_request({"year": 2019, "month": 1})
     return context, datasource, asset, batch_request
 
 
@@ -90,7 +90,7 @@ def spark_data(
         header=True,
         infer_schema=True,
     )
-    batch_request = asset.get_batch_request({"year": "2019", "month": "01"})
+    batch_request = asset.build_batch_request({"year": "2019", "month": "01"})
     return context, spark_ds, asset, batch_request
 
 
@@ -110,7 +110,7 @@ def multibatch_pandas_data(
         regex=r"yellow_tripdata_sample_(?P<year>\d{4})-(?P<month>\d{2})\.csv",
         order_by=["year", "month"],
     )
-    batch_request = asset.get_batch_request({"year": "2020"})
+    batch_request = asset.build_batch_request({"year": "2020"})
     return context, pandas_ds, asset, batch_request
 
 
@@ -128,7 +128,7 @@ def multibatch_sql_data(
         .add_year_and_month_splitter(column_name="pickup_datetime")
         .add_sorters(["year", "month"])
     )
-    batch_request = asset.get_batch_request({"year": 2020})
+    batch_request = asset.build_batch_request({"year": 2020})
     return context, datasource, asset, batch_request
 
 
@@ -150,7 +150,7 @@ def multibatch_spark_data(
         header=True,
         infer_schema=True,
     )
-    batch_request = asset.get_batch_request({"year": "2020"})
+    batch_request = asset.build_batch_request({"year": "2020"})
     return context, spark_ds, asset, batch_request
 
 
diff --git a/tests/experimental/datasources/integration/test_integration_datasource.py b/tests/experimental/datasources/integration/test_integration_datasource.py
index aeced9b6c..ca8f9afce 100644
--- a/tests/experimental/datasources/integration/test_integration_datasource.py
+++ b/tests/experimental/datasources/integration/test_integration_datasource.py
@@ -103,7 +103,7 @@ def test_sql_query_data_asset(empty_data_context):
         .add_sorters(["year"])
     )
     validator = context.get_validator(
-        batch_request=asset.get_batch_request({"year": 2019})
+        batch_request=asset.build_batch_request({"year": 2019})
     )
     result = validator.expect_column_distinct_values_to_equal_set(
         column="passenger_count",
diff --git a/tests/experimental/datasources/test_metadatasource.py b/tests/experimental/datasources/test_metadatasource.py
index 7dff794ed..ec099e222 100644
--- a/tests/experimental/datasources/test_metadatasource.py
+++ b/tests/experimental/datasources/test_metadatasource.py
@@ -22,7 +22,9 @@ from great_expectations.experimental.datasources.sources import (
 class DummyDataAsset(DataAsset):
     """Minimal Concrete DataAsset Implementation"""
 
-    def get_batch_request(self, options: Optional[BatchRequestOptions]) -> BatchRequest:
+    def build_batch_request(
+        self, options: Optional[BatchRequestOptions]
+    ) -> BatchRequest:
         return BatchRequest("datasource_name", "data_asset_name", options or {})
 
 
diff --git a/tests/experimental/datasources/test_pandas_datasource.py b/tests/experimental/datasources/test_pandas_datasource.py
index 87101177a..5f826f326 100644
--- a/tests/experimental/datasources/test_pandas_datasource.py
+++ b/tests/experimental/datasources/test_pandas_datasource.py
@@ -220,7 +220,7 @@ class TestDynamicPandasAssets:
                 regex=r"yellow_tripdata_sample_(?P<year>\d{4})-(?P<month>\d{2}).csv",
                 **extra_kwargs,
             )
-            .get_batch_request({"year": "2018"})
+            .build_batch_request({"year": "2018"})
         )
         with pytest.raises(SpyInterrupt):
             empty_data_context.get_validator(batch_request=batch_request)
@@ -320,7 +320,7 @@ def test_csv_asset_with_non_string_regex_named_parameters(
     )
     with pytest.raises(ge_exceptions.InvalidBatchRequestError):
         # year is an int which will raise an error
-        asset.get_batch_request({"year": 2018, "month": "04"})  # type: ignore[attr-defined]
+        asset.build_batch_request({"year": 2018, "month": "04"})  # type: ignore[attr-defined]
 
 
 @pytest.mark.unit
@@ -332,7 +332,7 @@ def test_get_batch_list_from_fully_specified_batch_request(
         base_directory=csv_path,
         regex=r"yellow_tripdata_sample_(?P<year>\d{4})-(?P<month>\d{2}).csv",
     )
-    request = asset.get_batch_request({"year": "2018", "month": "04"})  # type: ignore[attr-defined]
+    request = asset.build_batch_request({"year": "2018", "month": "04"})  # type: ignore[attr-defined]
     batches = asset.get_batch_list_from_batch_request(request)  # type: ignore[attr-defined]
     assert len(batches) == 1
     batch = batches[0]
@@ -369,7 +369,7 @@ def test_get_batch_list_from_partially_specified_batch_request(
         base_directory=csv_path,
         regex=r"yellow_tripdata_sample_(?P<year>\d{4})-(?P<month>\d{2}).csv",
     )
-    request = asset.get_batch_request({"year": "2018"})  # type: ignore[attr-defined]
+    request = asset.build_batch_request({"year": "2018"})  # type: ignore[attr-defined]
     batches = asset.get_batch_list_from_batch_request(request)  # type: ignore[attr-defined]
     assert (len(batches)) == 12
     batch_filenames = [
@@ -443,7 +443,7 @@ def test_pandas_sorter(
         regex=r"yellow_tripdata_sample_(?P<year>\d{4})-(?P<month>\d{2}).csv",
         order_by=order_by,
     )
-    batches = asset.get_batch_list_from_batch_request(asset.get_batch_request())  # type: ignore[attr-defined]
+    batches = asset.get_batch_list_from_batch_request(asset.build_batch_request())  # type: ignore[attr-defined]
     assert (len(batches)) == 36
 
     @dataclass(frozen=True)
diff --git a/tests/experimental/datasources/test_postgres_datasource.py b/tests/experimental/datasources/test_postgres_datasource.py
index 9718fa078..a9753d290 100644
--- a/tests/experimental/datasources/test_postgres_datasource.py
+++ b/tests/experimental/datasources/test_postgres_datasource.py
@@ -130,7 +130,7 @@ def test_add_table_asset_with_splitter(mocker, create_source: CreateSourceFixtur
             batch_request_template={"year": None, "month": None},
         )
         assert_batch_request(
-            batch_request=asset.get_batch_request({"year": 2021, "month": 10}),
+            batch_request=asset.build_batch_request({"year": 2021, "month": 10}),
             source_name="my_datasource",
             asset_name="my_asset",
             options={"year": 2021, "month": 10},
@@ -157,13 +157,13 @@ def test_add_table_asset_with_no_splitter(mocker, create_source: CreateSourceFix
             batch_request_template={},
         )
         assert_batch_request(
-            batch_request=asset.get_batch_request(),
+            batch_request=asset.build_batch_request(),
             source_name="my_datasource",
             asset_name="my_asset",
             options={},
         )
         assert_batch_request(
-            batch_request=asset.get_batch_request({}),
+            batch_request=asset.build_batch_request({}),
             source_name="my_datasource",
             asset_name="my_asset",
             options={},
@@ -177,7 +177,9 @@ def test_construct_table_asset_directly_with_no_splitter(create_source):
     ) as source:
         asset = TableAsset(name="my_asset", table_name="my_table")
         asset._datasource = source
-        assert_batch_request(asset.get_batch_request(), "my_datasource", "my_asset", {})
+        assert_batch_request(
+            asset.build_batch_request(), "my_datasource", "my_asset", {}
+        )
 
 
 def create_and_add_table_asset_without_testing_connection(
@@ -217,7 +219,7 @@ def test_construct_table_asset_directly_with_splitter(create_source):
         )
         batch_request_options = {"year": 2022, "month": 10}
         assert_batch_request(
-            asset.get_batch_request(batch_request_options),
+            asset.build_batch_request(batch_request_options),
             "my_datasource",
             "my_asset",
             batch_request_options,
@@ -241,7 +243,7 @@ def test_datasource_gets_batch_list_no_splitter(create_source):
         source, asset = create_and_add_table_asset_without_testing_connection(
             source=source, name="my_asset", table_name="my_table"
         )
-        source.get_batch_list_from_batch_request(asset.get_batch_request())
+        source.get_batch_list_from_batch_request(asset.build_batch_request())
 
 
 def assert_batch_specs_correct_with_year_month_splitter_defaults(batch_specs):
@@ -288,7 +290,7 @@ def test_datasource_gets_batch_list_splitter_with_unspecified_batch_request_opti
             source=source, name="my_asset", table_name="my_table"
         )
         asset.column_splitter = SqlYearMonthSplitter(column_name="my_col")
-        empty_batch_request = asset.get_batch_request()
+        empty_batch_request = asset.build_batch_request()
         assert empty_batch_request.options == {}
         batches = source.get_batch_list_from_batch_request(empty_batch_request)
         assert_batch_specs_correct_with_year_month_splitter_defaults(batch_specs)
@@ -311,7 +313,7 @@ def test_datasource_gets_batch_list_splitter_with_batch_request_options_set_to_n
             source=source, name="my_asset", table_name="my_table"
         )
         asset.column_splitter = SqlYearMonthSplitter(column_name="my_col")
-        batch_request_with_none = asset.get_batch_request(
+        batch_request_with_none = asset.build_batch_request(
             asset.batch_request_options_template()
         )
         assert batch_request_with_none.options == {"year": None, "month": None}
@@ -338,7 +340,7 @@ def test_datasource_gets_batch_list_splitter_with_partially_specified_batch_requ
         )
         asset.column_splitter = SqlYearMonthSplitter(column_name="my_col")
         batches = source.get_batch_list_from_batch_request(
-            asset.get_batch_request({"year": 2022})
+            asset.build_batch_request({"year": 2022})
         )
         assert len(batch_specs) == len(_DEFAULT_TEST_MONTHS)
         for month in _DEFAULT_TEST_MONTHS:
@@ -383,7 +385,7 @@ def test_datasource_gets_batch_list_with_fully_specified_batch_request_options(
         )
         asset.column_splitter = SqlYearMonthSplitter(column_name="my_col")
         batches = source.get_batch_list_from_batch_request(
-            asset.get_batch_request({"month": 1, "year": 2022})
+            asset.build_batch_request({"month": 1, "year": 2022})
         )
         assert 1 == len(batches)
         assert batches[0].metadata == {"month": 1, "year": 2022}
@@ -498,7 +500,7 @@ def test_get_bad_batch_request(create_source: CreateSourceFixture):
         )
         asset.column_splitter = SqlYearMonthSplitter(column_name="my_col")
         with pytest.raises(ge_exceptions.InvalidBatchRequestError):
-            asset.get_batch_request({"invalid_key": None})
+            asset.build_batch_request({"invalid_key": None})
 
 
 @pytest.mark.unit
@@ -831,7 +833,7 @@ def test_query_data_asset(create_source):
         )
         assert asset.name == "query_asset"
         assert asset.query.lower() == query.lower()
-        source.get_batch_list_from_batch_request(asset.get_batch_request())
+        source.get_batch_list_from_batch_request(asset.build_batch_request())
 
 
 @pytest.mark.unit
diff --git a/tests/experimental/datasources/test_spark_datasource.py b/tests/experimental/datasources/test_spark_datasource.py
index 6e35fdd35..a708608e0 100644
--- a/tests/experimental/datasources/test_spark_datasource.py
+++ b/tests/experimental/datasources/test_spark_datasource.py
@@ -139,7 +139,7 @@ def test_csv_asset_with_non_string_regex_named_parameters(
     )
     with pytest.raises(ge_exceptions.InvalidBatchRequestError):
         # year is an int which will raise an error
-        asset.get_batch_request({"year": 2018, "month": "04"})
+        asset.build_batch_request({"year": 2018, "month": "04"})
 
 
 @pytest.mark.unit
@@ -154,7 +154,7 @@ def test_get_batch_list_from_fully_specified_batch_request(
         header=True,
         infer_schema=True,
     )
-    request = asset.get_batch_request({"year": "2018", "month": "04"})
+    request = asset.build_batch_request({"year": "2018", "month": "04"})
     batches = asset.get_batch_list_from_batch_request(request)
     assert len(batches) == 1
     batch = batches[0]
@@ -194,7 +194,7 @@ def test_get_batch_list_from_partially_specified_batch_request(
         header=True,
         infer_schema=True,
     )
-    request = asset.get_batch_request({"year": "2018"})
+    request = asset.build_batch_request({"year": "2018"})
     batches = asset.get_batch_list_from_batch_request(request)
     assert (len(batches)) == 12
     batch_filenames = [
@@ -268,7 +268,7 @@ def test_spark_sorter(
         regex=r"yellow_tripdata_sample_(?P<year>\d{4})-(?P<month>\d{2}).csv",
         order_by=order_by,
     )
-    batches = asset.get_batch_list_from_batch_request(asset.get_batch_request())
+    batches = asset.get_batch_list_from_batch_request(asset.build_batch_request())
     assert (len(batches)) == 36
 
     @dataclass(frozen=True)
diff --git a/tests/experimental/datasources/test_viral_snippets.py b/tests/experimental/datasources/test_viral_snippets.py
index a0cf490b4..47f13ceb0 100644
--- a/tests/experimental/datasources/test_viral_snippets.py
+++ b/tests/experimental/datasources/test_viral_snippets.py
@@ -146,7 +146,7 @@ def test_serialize_zep_config(zep_file_context: FileDataContext):
 def test_zep_simple_validate_workflow(zep_file_context: FileDataContext):
     datasource = zep_file_context.get_datasource("my_sql_ds")
     assert isinstance(datasource, Datasource)
-    batch_request = datasource.get_asset("my_asset").get_batch_request(
+    batch_request = datasource.get_asset("my_asset").build_batch_request(
         {"year": 2019, "month": 1}
     )
 
diff --git a/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant_happy_paths.py b/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant_happy_paths.py
index 717ea89bd..9bf814544 100644
--- a/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant_happy_paths.py
+++ b/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant_happy_paths.py
@@ -466,7 +466,7 @@ def test_sql_happy_path_onboarding_data_assistant_mixed_decimal_float_and_boolea
         .add_sorters(["year", "-month"])
     )
 
-    batch_request = data_asset.get_batch_request(batch_options)
+    batch_request = data_asset.build_batch_request(batch_options)
 
     result = context.assistants.onboarding.run(
         batch_request=batch_request,