Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Deprecate DataContext.add_or_update_datasource #10784

Merged
merged 8 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -761,6 +762,7 @@
...

@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,
Expand All @@ -778,6 +780,12 @@
Returns:
The Datasource added or updated by the input `kwargs`.
""" # noqa: E501
# deprecated-v1.3.0
warnings.warn(

Check warning on line 784 in great_expectations/data_context/data_context/abstract_data_context.py

View check run for this annotation

Codecov / codecov/patch

great_expectations/data_context/data_context/abstract_data_context.py#L784

Added line #L784 was not covered by tests
"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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
10 changes: 1 addition & 9 deletions tests/integration/cloud/end_to_end/test_spark_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,14 @@ 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.add_or_update_datasource(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()
datasource = context.data_sources.add_or_update_spark(**datasource_dict)
assert (
datasource.persist is False
), "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)
assert datasource.persist is True, "The datasource was not updated in the previous method call."
return datasource

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 0 additions & 1 deletion tests/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading