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

add user agent string #672

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

add user agent string #672

wants to merge 4 commits into from

Conversation

joshua-stauffer
Copy link
Member

GX Core has recently added functionality which allows us to specify the the run environment for analytics. This PR updates the agent to use it.

Copy link

codecov bot commented Feb 14, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
195 1 194 2
View the top 1 failed test(s) by shortest run time
tests.agent.test_agent::test_gx_agent_initializes_cloud_context
Stack Traces | 0.018s run time
self = <MagicMock name='get_context' id='140128095378448'>, args = ()
kwargs = {'cloud_mode': True}, expected = call(cloud_mode=True)
actual = call(cloud_mode=True, user_agent_str='gx-agent')
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f721c4c8540>
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: get_context(cloud_mode=True)
E             Actual: get_context(cloud_mode=True, user_agent_str='gx-agent')

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

During handling of the above exception, another exception occurred:

get_context = <MagicMock name='get_context' id='140128095378448'>
gx_agent_config = GXAgentConfig(queue='3ee9791c-4ea6-479d-9b05-98217e70d341', connection_string=AmqpDsn('amqps://user:pass@great_expecta...ion_id='ec22905c-8e8e-4d63-bb03-a47badc899b7', gx_cloud_access_token='13CR2yyXr8VwXxHdbiU0', enable_progress_bars=True)

    def test_gx_agent_initializes_cloud_context(get_context, gx_agent_config):
        GXAgent()
>       get_context.assert_called_with(cloud_mode=True)
E       AssertionError: expected call not found.
E       Expected: get_context(cloud_mode=True)
E         Actual: get_context(cloud_mode=True, user_agent_str='gx-agent')
E       
E       pytest introspection follows:
E       
E       Kwargs:
E       assert equals failed
E         #x00-{#x01                                                                
E         #x00^  #x01'cloud_mode': True#x00^,#x01            #x00^{#x01'cloud_mode': True#x00^}#x01            
E         #x00-  'user_agent_str': 'gx-agent',#x01                                  
E         #x00-}#x01

tests/agent/test_agent.py:247: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@@ -156,7 +156,9 @@ def __init__(self: Self):
with warnings.catch_warnings():
# suppress warnings about GX version
warnings.filterwarnings("ignore", message="You are using great_expectations version")
self._context: CloudDataContext = get_context(cloud_mode=True)
self._context: CloudDataContext = get_context(
cloud_mode=True, user_agent_str="gx-agent"
Copy link
Contributor

@tyler-hoffman tyler-hoffman Feb 14, 2025

Choose a reason for hiding this comment

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

Classic bikeshedding on a one-line PR. The intended format (copied from the PR that added the value) is user_agent_str: Optional string, should be of format <PRODUCT> / <VERSION> <COMMENT> where comment is optional. Can we do user_agent_str=f"gx-agent / {__version__}"?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

Copy link
Contributor

@tyler-hoffman tyler-hoffman left a comment

Choose a reason for hiding this comment

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

requesting an update to the form of the agent str

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.

4 participants