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] prioritize env variable setting over cloud context for … #10859

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

shiplet
Copy link
Contributor

@shiplet shiplet commented Jan 15, 2025

…analytics enabled

  • Description of PR changes above includes a link to an existing GitHub issue
  • PR title is prefixed with one of: [BUGFIX], [FEATURE], [DOCS], [MAINTENANCE], [CONTRIB]
  • Code is linted - run invoke lint (uses ruff format + ruff check)
  • Appropriate tests and docs have been updated

For more information about contributing, visit our community resources.

After you submit your PR, keep the page open and monitor the statuses of the various checks made by our continuous integration process at the bottom of the page. Please fix any issues that come up and reach out on Slack if you need help. Thanks for contributing!

Copy link

netlify bot commented Jan 15, 2025

Deploy Preview for niobium-lead-7998 canceled.

Name Link
🔨 Latest commit a8bc4a1
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/6788221d56b3460008b7739c

Copy link

codecov bot commented Jan 15, 2025

❌ 24 Tests Failed:

Tests completed Failed Passed Skipped
8388 24 8364 702
View the top 3 failed tests by shortest run time
tests.analytics.test_analytics::test_analytics_enabled_on_load[True-False-False]
Stack Traces | 0.039s run time
self = <MagicMock name='init_analytics' id='140163003456528'>, args = ()
kwargs = {'data_context_id': <ANY>, 'enable': False, 'organization_id': <ANY>, 'oss_id': <ANY>, ...}
expected = call(enable=False, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
actual = call(enable=True, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('12c974f9-f1bb-4478-95cd-a7c80c94eb3b'))
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f7a3b4a9c10>
cause = None

    def assert_called_with(self, /, *args, **kwargs):
        """assert that the last call was made with the specified arguments.
    
        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock."""
        if self.call_args is None:
            expected = self._format_mock_call_signature(args, kwargs)
            actual = 'not called.'
            error_message = ('expected call not found.\nExpected: %s\nActual: %s'
                    % (expected, actual))
            raise AssertionError(error_message)
    
        def _error_message():
            msg = self._format_mock_failure_message(args, kwargs)
            return msg
        expected = self._call_matcher(_Call((args, kwargs), two=True))
        actual = self._call_matcher(self.call_args)
        if actual != expected:
            cause = expected if isinstance(expected, Exception) else None
>           raise AssertionError(_error_message()) from cause
E           AssertionError: expected call not found.
E           Expected: init_analytics(enable=False, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
E           Actual: init_analytics(enable=True, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('12c974f9-f1bb-4478-95cd-a7c80c94eb3b'))

.../hostedtoolcache/Python/3.9.21.../x64/lib/python3.9/unittest/mock.py:907: AssertionError

During handling of the above exception, another exception occurred:

environment_variable = True, constructor_variable = False
expected_value = False
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f7a3dd95c40>

    @pytest.mark.parametrize(
        ("environment_variable", "constructor_variable", "expected_value"),
        [
            (False, None, False),
            (False, False, False),
            (False, True, True),  # enabling in config overrides environment variable
            (True, None, True),
            (True, False, False),
            (True, True, True),
        ],
    )
    @pytest.mark.unit
    def test_analytics_enabled_on_load(
        environment_variable: bool,
        constructor_variable: Optional[bool],
        expected_value: bool,
        monkeypatch,
    ):
        monkeypatch.setattr(ENV_CONFIG, "gx_analytics_enabled", environment_variable)
        project_config = DataContextConfig(
            store_backend_defaults=InMemoryStoreBackendDefaults(init_temp_docs_sites=True),
            analytics_enabled=constructor_variable,
        )
    
        with mock.patch(
            "great_expectations.data_context.data_context.abstract_data_context.init_analytics"
        ) as mock_init:
            gx.get_context(
                mode="ephemeral",
                project_config=project_config,
            )
    
>       mock_init.assert_called_with(
            enable=expected_value,
            data_context_id=mock.ANY,
            organization_id=mock.ANY,
            oss_id=mock.ANY,
            user_id=mock.ANY,
        )
E       AssertionError: expected call not found.
E       Expected: init_analytics(enable=False, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
E       Actual: init_analytics(enable=True, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('12c974f9-f1bb-4478-95cd-a7c80c94eb3b'))
E       
E       pytest introspection follows:
E       
E       Kwargs:
E       assert equals failed
E         {                                {                               
E           'data_context_id': N#x00^one#x01,         'data_context_id': #x00+<A#x01N#x00^Y>#x01,     
E           'enable': #x00^Tru#x01e,                  'enable': #x00^Fals#x01e,              
E           'organization_id': N#x00^one#x01,         'organization_id': #x00+<A#x01N#x00^Y>#x01,     
E         #x00-  'oss_id': UUID('12c974f9-f1bb#x01  #x00+  'oss_id': <ANY>,#x01              
E         #x00--4478-95cd-a7c80c94eb3b'),#x01                                       
E           'user_id': N#x00^one#x01,                 'user_id': #x00+<A#x01N#x00^Y>#x01,             
E         }                                }

tests/analytics/test_analytics.py:184: AssertionError
tests.analytics.test_analytics::test_analytics_enabled_on_load[True-False-False]
Stack Traces | 0.039s run time
self = <MagicMock name='init_analytics' id='140048092818192'>, args = ()
kwargs = {'data_context_id': <ANY>, 'enable': False, 'organization_id': <ANY>, 'oss_id': <ANY>, ...}
expected = call(enable=False, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
actual = call(enable=True, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('cf2727dd-3dc9-4659-8dd0-1561b6afe1bf'))
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f5f7b65e2a0>
cause = None

    def assert_called_with(self, /, *args, **kwargs):
        """assert that the last call was made with the specified arguments.
    
        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock."""
        if self.call_args is None:
            expected = self._format_mock_call_signature(args, kwargs)
            actual = 'not called.'
            error_message = ('expected call not found.\nExpected: %s\n  Actual: %s'
                    % (expected, actual))
            raise AssertionError(error_message)
    
        def _error_message():
            msg = self._format_mock_failure_message(args, kwargs)
            return msg
        expected = self._call_matcher(_Call((args, kwargs), two=True))
        actual = self._call_matcher(self.call_args)
        if actual != expected:
            cause = expected if isinstance(expected, Exception) else None
>           raise AssertionError(_error_message()) from cause
E           AssertionError: expected call not found.
E           Expected: init_analytics(enable=False, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
E             Actual: init_analytics(enable=True, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('cf2727dd-3dc9-4659-8dd0-1561b6afe1bf'))

.../hostedtoolcache/Python/3.11.11.../x64/lib/python3.11/unittest/mock.py:939: AssertionError

During handling of the above exception, another exception occurred:

environment_variable = True, constructor_variable = False
expected_value = False
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f5f7d7ffc10>

    @pytest.mark.parametrize(
        ("environment_variable", "constructor_variable", "expected_value"),
        [
            (False, None, False),
            (False, False, False),
            (False, True, True),  # enabling in config overrides environment variable
            (True, None, True),
            (True, False, False),
            (True, True, True),
        ],
    )
    @pytest.mark.unit
    def test_analytics_enabled_on_load(
        environment_variable: bool,
        constructor_variable: Optional[bool],
        expected_value: bool,
        monkeypatch,
    ):
        monkeypatch.setattr(ENV_CONFIG, "gx_analytics_enabled", environment_variable)
        project_config = DataContextConfig(
            store_backend_defaults=InMemoryStoreBackendDefaults(init_temp_docs_sites=True),
            analytics_enabled=constructor_variable,
        )
    
        with mock.patch(
            "great_expectations.data_context.data_context.abstract_data_context.init_analytics"
        ) as mock_init:
            gx.get_context(
                mode="ephemeral",
                project_config=project_config,
            )
    
>       mock_init.assert_called_with(
            enable=expected_value,
            data_context_id=mock.ANY,
            organization_id=mock.ANY,
            oss_id=mock.ANY,
            user_id=mock.ANY,
        )
E       AssertionError: expected call not found.
E       Expected: init_analytics(enable=False, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
E         Actual: init_analytics(enable=True, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('cf2727dd-3dc9-4659-8dd0-1561b6afe1bf'))
E       
E       pytest introspection follows:
E       
E       Kwargs:
E       assert equals failed
E         {                                {                               
E           'data_context_id': N#x00^one#x01,         'data_context_id': #x00+<A#x01N#x00^Y>#x01,     
E           'enable': #x00^Tru#x01e,                  'enable': #x00^Fals#x01e,              
E           'organization_id': N#x00^one#x01,         'organization_id': #x00+<A#x01N#x00^Y>#x01,     
E         #x00-  'oss_id': UUID('cf2727dd-3dc9#x01  #x00+  'oss_id': <ANY>,#x01              
E         #x00--4659-8dd0-1561b6afe1bf'),#x01                                       
E           'user_id': N#x00^one#x01,                 'user_id': #x00+<A#x01N#x00^Y>#x01,             
E         }                                }

tests/analytics/test_analytics.py:184: AssertionError
tests.analytics.test_analytics::test_analytics_enabled_on_load[False-True-True]
Stack Traces | 0.04s run time
self = <MagicMock name='init_analytics' id='140163033851936'>, args = ()
kwargs = {'data_context_id': <ANY>, 'enable': True, 'organization_id': <ANY>, 'oss_id': <ANY>, ...}
expected = call(enable=True, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
actual = call(enable=False, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('12c974f9-f1bb-4478-95cd-a7c80c94eb3b'))
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f7a6d5b89d0>
cause = None

    def assert_called_with(self, /, *args, **kwargs):
        """assert that the last call was made with the specified arguments.
    
        Raises an AssertionError if the args and keyword args passed in are
        different to the last call to the mock."""
        if self.call_args is None:
            expected = self._format_mock_call_signature(args, kwargs)
            actual = 'not called.'
            error_message = ('expected call not found.\nExpected: %s\nActual: %s'
                    % (expected, actual))
            raise AssertionError(error_message)
    
        def _error_message():
            msg = self._format_mock_failure_message(args, kwargs)
            return msg
        expected = self._call_matcher(_Call((args, kwargs), two=True))
        actual = self._call_matcher(self.call_args)
        if actual != expected:
            cause = expected if isinstance(expected, Exception) else None
>           raise AssertionError(_error_message()) from cause
E           AssertionError: expected call not found.
E           Expected: init_analytics(enable=True, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
E           Actual: init_analytics(enable=False, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('12c974f9-f1bb-4478-95cd-a7c80c94eb3b'))

.../hostedtoolcache/Python/3.9.21.../x64/lib/python3.9/unittest/mock.py:907: AssertionError

During handling of the above exception, another exception occurred:

environment_variable = False, constructor_variable = True, expected_value = True
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f7a3fd7e730>

    @pytest.mark.parametrize(
        ("environment_variable", "constructor_variable", "expected_value"),
        [
            (False, None, False),
            (False, False, False),
            (False, True, True),  # enabling in config overrides environment variable
            (True, None, True),
            (True, False, False),
            (True, True, True),
        ],
    )
    @pytest.mark.unit
    def test_analytics_enabled_on_load(
        environment_variable: bool,
        constructor_variable: Optional[bool],
        expected_value: bool,
        monkeypatch,
    ):
        monkeypatch.setattr(ENV_CONFIG, "gx_analytics_enabled", environment_variable)
        project_config = DataContextConfig(
            store_backend_defaults=InMemoryStoreBackendDefaults(init_temp_docs_sites=True),
            analytics_enabled=constructor_variable,
        )
    
        with mock.patch(
            "great_expectations.data_context.data_context.abstract_data_context.init_analytics"
        ) as mock_init:
            gx.get_context(
                mode="ephemeral",
                project_config=project_config,
            )
    
>       mock_init.assert_called_with(
            enable=expected_value,
            data_context_id=mock.ANY,
            organization_id=mock.ANY,
            oss_id=mock.ANY,
            user_id=mock.ANY,
        )
E       AssertionError: expected call not found.
E       Expected: init_analytics(enable=True, data_context_id=<ANY>, organization_id=<ANY>, oss_id=<ANY>, user_id=<ANY>)
E       Actual: init_analytics(enable=False, user_id=None, data_context_id=None, organization_id=None, oss_id=UUID('12c974f9-f1bb-4478-95cd-a7c80c94eb3b'))
E       
E       pytest introspection follows:
E       
E       Kwargs:
E       assert equals failed
E         {                                {                               
E           'data_context_id': N#x00^one#x01,         'data_context_id': #x00+<A#x01N#x00^Y>#x01,     
E           'enable': #x00^Fals#x01e,                 'enable': #x00^Tru#x01e,               
E           'organization_id': N#x00^one#x01,         'organization_id': #x00+<A#x01N#x00^Y>#x01,     
E         #x00-  'oss_id': UUID('12c974f9-f1bb#x01  #x00+  'oss_id': <ANY>,#x01              
E         #x00--4478-95cd-a7c80c94eb3b'),#x01                                       
E           'user_id': N#x00^one#x01,                 'user_id': #x00+<A#x01N#x00^Y>#x01,             
E         }                                }

tests/analytics/test_analytics.py:184: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant