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] Ensure that DataContextConfig has a consistent shape when args are omitted #9469

Merged
merged 8 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 4 additions & 11 deletions great_expectations/data_context/types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ class DataContextConfig(BaseYamlConfig):
globally, at the ExpectationSuite or ExpectationValidationResults-level.
"""

def __init__( # noqa: C901, PLR0912, PLR0913, PLR0915
def __init__( # noqa: C901, PLR0912, PLR0913
self,
batch_configs: Optional[Dict] = None,
config_version: Optional[float] = None,
Expand All @@ -2327,7 +2327,6 @@ def __init__( # noqa: C901, PLR0912, PLR0913, PLR0915
plugins_directory: Optional[str] = None,
validation_operators=None,
stores: Optional[Dict] = None,
notebooks: Optional[Any] = None,
data_docs_sites: Optional[Dict] = None,
config_variables_file_path: Optional[str] = None,
anonymous_usage_statistics: Optional[AnonymizedUsageStatisticsConfig] = None,
Expand All @@ -2337,9 +2336,6 @@ def __init__( # noqa: C901, PLR0912, PLR0913, PLR0915
progress_bars: Optional[ProgressBarsConfig] = None,
include_rendered_content: Optional[IncludeRenderedContentConfig] = None,
) -> None:
if notebooks:
warnings.warn("The `notebooks` parameter no longer supported.", UserWarning)

# Set defaults
if config_version is None:
config_version = DataContextConfigDefaults.DEFAULT_CONFIG_VERSION.value
Expand Down Expand Up @@ -2373,13 +2369,10 @@ def __init__( # noqa: C901, PLR0912, PLR0913, PLR0915
self.expectations_store_name = expectations_store_name
self.validations_store_name = validations_store_name
self.evaluation_parameter_store_name = evaluation_parameter_store_name
if checkpoint_store_name is not None:
self.checkpoint_store_name = checkpoint_store_name
if profiler_store_name is not None:
self.profiler_store_name = profiler_store_name
self.checkpoint_store_name = checkpoint_store_name
self.profiler_store_name = profiler_store_name
self.plugins_directory = plugins_directory
if validation_operators is not None:
self.validation_operators = validation_operators
Comment on lines -2376 to -2382
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These feel bad. I shouldn't have the reason about whether or not an object has an attr. Shape should be consistent (even if values are not!)

self.validation_operators = validation_operators
self.stores = stores or {}
self.data_docs_sites = data_docs_sites
self.config_variables_file_path = config_variables_file_path
Expand Down
2 changes: 2 additions & 0 deletions tests/data_context/store/test_store_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,10 @@ def test_InlineStoreBackend(empty_data_context) -> None:
("fluent_datasources",),
("include_rendered_content",),
("plugins_directory",),
("profiler_store_name",),
("progress_bars",),
("stores",),
("validation_operators",),
("validations_store_name",),
]

Expand Down
36 changes: 36 additions & 0 deletions tests/data_context/test_data_context_config_ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import os
from typing import Dict, Final, Optional
from unittest import mock

import pytest

Expand Down Expand Up @@ -1560,3 +1561,38 @@ def test_DataContextConfig_with_InMemoryStoreBackendDefaults(
),
DataContextConfig,
)


@pytest.mark.unit
def test_data_context_config_defaults():
config = DataContextConfig()
assert config.to_json_dict() == {
"anonymous_usage_statistics": {
"data_context_id": mock.ANY,
"enabled": True,
"explicit_id": False,
"explicit_url": False,
"usage_statistics_url": "https://stats.greatexpectations.io/great_expectations/v1/usage_statistics",
},
"batch_configs": {},
"checkpoint_store_name": None,
"concurrency": None,
"config_variables_file_path": None,
"config_version": 3,
"data_docs_sites": None,
"datasources": {},
"evaluation_parameter_store_name": None,
"expectations_store_name": None,
"fluent_datasources": {},
"include_rendered_content": {
"expectation_suite": False,
"expectation_validation_result": False,
"globally": False,
},
"plugins_directory": None,
"profiler_store_name": None,
"progress_bars": None,
"stores": {},
"validation_operators": None,
"validations_store_name": None,
}
3 changes: 3 additions & 0 deletions tests/data_context/test_data_context_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ def test_data_context_variables_save_config(
):
expected_config_dict[attr] = data_context_config_dict[attr]

# Add null values for stores that are not configured
expected_config_dict["profiler_store_name"] = None

assert mock_put.call_count == 1
mock_put.assert_called_with(
mock.ANY, # requests.Session object
Expand Down