From 9455cb7ef9abed08bb87803b6ac7ce5f6bc8dfc7 Mon Sep 17 00:00:00 2001 From: Chetan Kini Date: Mon, 16 Dec 2024 15:39:16 -0500 Subject: [PATCH 1/3] deprecate --- .../data_context/data_context/abstract_data_context.py | 8 ++++++++ .../cloud/end_to_end/test_pandas_datasource.py | 2 +- .../cloud/end_to_end/test_pandas_filesystem_datasource.py | 2 +- .../integration/cloud/end_to_end/test_spark_datasource.py | 4 ++-- .../cloud/end_to_end/test_spark_filesystem_datasource.py | 2 +- tests/test_deprecation.py | 1 - 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/great_expectations/data_context/data_context/abstract_data_context.py b/great_expectations/data_context/data_context/abstract_data_context.py index 1cd57b3e6a9b..fa1df99c61d6 100644 --- a/great_expectations/data_context/data_context/abstract_data_context.py +++ b/great_expectations/data_context/data_context/abstract_data_context.py @@ -29,6 +29,7 @@ import great_expectations as gx import great_expectations.exceptions as gx_exceptions from great_expectations._docs_decorators import ( + deprecated_method_or_class, new_argument, new_method_or_class, public_api, @@ -761,6 +762,7 @@ def add_or_update_datasource( ... @new_method_or_class(version="0.15.48") + @deprecated_method_or_class(version="1.3.0") def add_or_update_datasource( self, name: str | None = None, @@ -778,6 +780,12 @@ def add_or_update_datasource( Returns: The Datasource added or updated by the input `kwargs`. """ # noqa: E501 + # deprecated-v1.3.0 + warnings.warn( + "add_or_update_datasource() from the DataContext is deprecated and will be removed " + "in a future version of GX. Please use `context.data_sources.add_or_update` instead.", + category=DeprecationWarning, + ) self._validate_add_datasource_args(name=name, datasource=datasource) return_datasource: FluentDatasource diff --git a/tests/integration/cloud/end_to_end/test_pandas_datasource.py b/tests/integration/cloud/end_to_end/test_pandas_datasource.py index 0ffe063ca045..4ac69ec65a44 100644 --- a/tests/integration/cloud/end_to_end/test_pandas_datasource.py +++ b/tests/integration/cloud/end_to_end/test_pandas_datasource.py @@ -39,7 +39,7 @@ def datasource( datasource.name == new_datasource_name ), "The datasource was not updated in the previous method call." datasource.name = datasource_name - datasource = context.add_or_update_datasource( # type: ignore[assignment] + datasource = context.data_sources.add_or_update_pandas( datasource=datasource, ) assert ( diff --git a/tests/integration/cloud/end_to_end/test_pandas_filesystem_datasource.py b/tests/integration/cloud/end_to_end/test_pandas_filesystem_datasource.py index c36da1011353..9b6f5a8c7323 100644 --- a/tests/integration/cloud/end_to_end/test_pandas_filesystem_datasource.py +++ b/tests/integration/cloud/end_to_end/test_pandas_filesystem_datasource.py @@ -75,7 +75,7 @@ def datasource( ), "The datasource was not updated in the previous method call." datasource.base_directory = original_base_dir - datasource = context.add_or_update_datasource(datasource=datasource) # type: ignore[assignment] + datasource = context.data_sources.add_or_update_pandas_filesystem(datasource=datasource) assert ( datasource.base_directory == original_base_dir ), "The datasource was not updated in the previous method call." diff --git a/tests/integration/cloud/end_to_end/test_spark_datasource.py b/tests/integration/cloud/end_to_end/test_spark_datasource.py index 6f21d58f9f00..c0920b6bf2db 100644 --- a/tests/integration/cloud/end_to_end/test_spark_datasource.py +++ b/tests/integration/cloud/end_to_end/test_spark_datasource.py @@ -41,7 +41,7 @@ def datasource( datasource.persist is False ), "The datasource was not updated in the previous method call." datasource.persist = True - datasource = context.add_or_update_datasource(datasource=datasource) # type: ignore[assignment] + datasource = context.data_sources.add_or_update_spark(datasource=datasource) # type: ignore[assignment] assert datasource.persist is True, "The datasource was not updated in the previous method call." datasource.persist = False datasource_dict = datasource.dict() @@ -51,7 +51,7 @@ def datasource( ), "The datasource was not updated in the previous method call." datasource.persist = True datasource_dict = datasource.dict() - datasource = context.add_or_update_datasource(**datasource_dict) # type: ignore[assignment] + datasource = context.data_sources.add_or_update_spark(**datasource_dict) # type: ignore[assignment] assert datasource.persist is True, "The datasource was not updated in the previous method call." return datasource diff --git a/tests/integration/cloud/end_to_end/test_spark_filesystem_datasource.py b/tests/integration/cloud/end_to_end/test_spark_filesystem_datasource.py index b30c95764ded..8107f71b300c 100644 --- a/tests/integration/cloud/end_to_end/test_spark_filesystem_datasource.py +++ b/tests/integration/cloud/end_to_end/test_spark_filesystem_datasource.py @@ -68,7 +68,7 @@ def datasource( ), "The datasource was not updated in the previous method call." datasource.base_directory = normalize_directory_path(original_base_dir, context.root_directory) - datasource = context.add_or_update_datasource(datasource=datasource) # type: ignore[assignment] + datasource = context.data_sources.add_or_update_spark_filesystem(datasource=datasource) assert ( datasource.base_directory == original_base_dir ), "The datasource was not updated in the previous method call." diff --git a/tests/test_deprecation.py b/tests/test_deprecation.py index 4f874981f3e2..8c02b6b26ef7 100644 --- a/tests/test_deprecation.py +++ b/tests/test_deprecation.py @@ -30,7 +30,6 @@ def files_with_deprecation_warnings() -> List[str]: "great_expectations/compatibility/pyspark.py", "great_expectations/compatibility/sqlalchemy_and_pandas.py", "great_expectations/compatibility/sqlalchemy_compatibility_wrappers.py", - "great_expectations/rule_based_profiler/altair/encodings.py", # ignoring because of imprecise matching logic # noqa: E501 ] for file_to_exclude in files_to_exclude: if file_to_exclude in files: From 20cbc40c0bfaade3bff7928d234e3c00f402a80d Mon Sep 17 00:00:00 2001 From: Chetan Kini Date: Mon, 16 Dec 2024 16:16:00 -0500 Subject: [PATCH 2/3] try again --- tests/integration/cloud/end_to_end/test_spark_datasource.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/cloud/end_to_end/test_spark_datasource.py b/tests/integration/cloud/end_to_end/test_spark_datasource.py index c0920b6bf2db..e812481abe70 100644 --- a/tests/integration/cloud/end_to_end/test_spark_datasource.py +++ b/tests/integration/cloud/end_to_end/test_spark_datasource.py @@ -41,7 +41,7 @@ def datasource( datasource.persist is False ), "The datasource was not updated in the previous method call." datasource.persist = True - datasource = context.data_sources.add_or_update_spark(datasource=datasource) # type: ignore[assignment] + datasource = context.data_sources.add_or_update_spark(datasource=datasource) # type: ignore[call_arg] assert datasource.persist is True, "The datasource was not updated in the previous method call." datasource.persist = False datasource_dict = datasource.dict() @@ -51,7 +51,7 @@ def datasource( ), "The datasource was not updated in the previous method call." datasource.persist = True datasource_dict = datasource.dict() - datasource = context.data_sources.add_or_update_spark(**datasource_dict) # type: ignore[assignment] + datasource = context.data_sources.add_or_update_spark(**datasource_dict) assert datasource.persist is True, "The datasource was not updated in the previous method call." return datasource From 7a9836b66ac23911d1b6dc526fbf0a2efa321c9b Mon Sep 17 00:00:00 2001 From: Chetan Kini Date: Tue, 17 Dec 2024 13:28:03 -0500 Subject: [PATCH 3/3] update call --- .../integration/cloud/end_to_end/test_spark_datasource.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/integration/cloud/end_to_end/test_spark_datasource.py b/tests/integration/cloud/end_to_end/test_spark_datasource.py index e812481abe70..48e8bbd6b1eb 100644 --- a/tests/integration/cloud/end_to_end/test_spark_datasource.py +++ b/tests/integration/cloud/end_to_end/test_spark_datasource.py @@ -36,14 +36,6 @@ def datasource( persist=True, ) datasource.persist = False - datasource = context.data_sources.add_or_update_spark(datasource=datasource) # type: ignore[call-arg] - assert ( - datasource.persist is False - ), "The datasource was not updated in the previous method call." - datasource.persist = True - datasource = context.data_sources.add_or_update_spark(datasource=datasource) # type: ignore[call_arg] - assert datasource.persist is True, "The datasource was not updated in the previous method call." - datasource.persist = False datasource_dict = datasource.dict() datasource = context.data_sources.add_or_update_spark(**datasource_dict) assert (