From ac75456d3a60caca0c55d1630f1cad363235f045 Mon Sep 17 00:00:00 2001 From: blaise-muhirwa Date: Tue, 2 Apr 2024 14:29:32 -0700 Subject: [PATCH 1/9] change the user agent header --- src/groundlight/internalapi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/groundlight/internalapi.py b/src/groundlight/internalapi.py index 2ef6125c..0c6ee50c 100644 --- a/src/groundlight/internalapi.py +++ b/src/groundlight/internalapi.py @@ -168,6 +168,10 @@ class GroundlightApiClient(ApiClient): templates in the generator to add the functionality. """ + def __init__(self): + super().__init__() + self.user_agent = f"Groundlight-Python-SDK/{get_version()}" + REQUEST_ID_HEADER = "X-Request-Id" @RequestsRetryDecorator() From 023eee7254875cfcbc9321b5607789cb983a9f62 Mon Sep 17 00:00:00 2001 From: blaise-muhirwa Date: Tue, 2 Apr 2024 14:33:00 -0700 Subject: [PATCH 2/9] fix constructor error --- src/groundlight/internalapi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/groundlight/internalapi.py b/src/groundlight/internalapi.py index 0c6ee50c..596cbf63 100644 --- a/src/groundlight/internalapi.py +++ b/src/groundlight/internalapi.py @@ -168,8 +168,8 @@ class GroundlightApiClient(ApiClient): templates in the generator to add the functionality. """ - def __init__(self): - super().__init__() + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) self.user_agent = f"Groundlight-Python-SDK/{get_version()}" REQUEST_ID_HEADER = "X-Request-Id" From b8c88d09d5373647f1fcedda7b7a7fadacbc02f2 Mon Sep 17 00:00:00 2001 From: blaise-muhirwa Date: Tue, 2 Apr 2024 14:51:11 -0700 Subject: [PATCH 3/9] force an exception --- src/groundlight/client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index bf5070e2..a27d20fd 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -418,6 +418,10 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments, t :return: ImageQuery """ + + value = 1 / 0 + + if wait is None: wait = self.DEFAULT_WAIT From cb704f85db3e4dfda501d9de7c0cb6ff176010a8 Mon Sep 17 00:00:00 2001 From: Auto-format Bot Date: Tue, 2 Apr 2024 21:51:53 +0000 Subject: [PATCH 4/9] Automatically reformatting code --- src/groundlight/client.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index a27d20fd..77d41def 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -418,10 +418,7 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments, t :return: ImageQuery """ - - value = 1 / 0 - - + if wait is None: wait = self.DEFAULT_WAIT From f801b83719e470f2cf51cd8f6b74d36c235568fe Mon Sep 17 00:00:00 2001 From: blaise-muhirwa Date: Tue, 2 Apr 2024 15:16:41 -0700 Subject: [PATCH 5/9] checking if the header was updated --- src/groundlight/client.py | 4 ---- src/groundlight/internalapi.py | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index a27d20fd..bf5070e2 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -418,10 +418,6 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments, t :return: ImageQuery """ - - value = 1 / 0 - - if wait is None: wait = self.DEFAULT_WAIT diff --git a/src/groundlight/internalapi.py b/src/groundlight/internalapi.py index 596cbf63..812e481e 100644 --- a/src/groundlight/internalapi.py +++ b/src/groundlight/internalapi.py @@ -186,6 +186,10 @@ def call_api(self, *args, **kwargs): elif not header_param.get(self.REQUEST_ID_HEADER, None): header_param[self.REQUEST_ID_HEADER] = _generate_request_id() # Note that we have updated the actual dict in args, so we don't have to put it back in + + logger.info(f"Args: {args}") + logger.info(f"Kwargs: {kwargs}") + return super().call_api(*args, **kwargs) # From 92d5f1273dc7edbec372af56381d948c9b66ebf9 Mon Sep 17 00:00:00 2001 From: Auto-format Bot Date: Tue, 2 Apr 2024 22:18:14 +0000 Subject: [PATCH 6/9] Automatically reformatting code --- src/groundlight/internalapi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/groundlight/internalapi.py b/src/groundlight/internalapi.py index 812e481e..82b31423 100644 --- a/src/groundlight/internalapi.py +++ b/src/groundlight/internalapi.py @@ -186,10 +186,10 @@ def call_api(self, *args, **kwargs): elif not header_param.get(self.REQUEST_ID_HEADER, None): header_param[self.REQUEST_ID_HEADER] = _generate_request_id() # Note that we have updated the actual dict in args, so we don't have to put it back in - + logger.info(f"Args: {args}") logger.info(f"Kwargs: {kwargs}") - + return super().call_api(*args, **kwargs) # From 7ed650be397882804a99a792b0bd13a7f0cbb68a Mon Sep 17 00:00:00 2001 From: blaise-muhirwa Date: Tue, 2 Apr 2024 15:51:31 -0700 Subject: [PATCH 7/9] check that the header is updated --- generated/openapi_client/api_client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generated/openapi_client/api_client.py b/generated/openapi_client/api_client.py index b8909270..af2de95d 100644 --- a/generated/openapi_client/api_client.py +++ b/generated/openapi_client/api_client.py @@ -139,6 +139,10 @@ def __call_api( # header parameters header_params = header_params or {} header_params.update(self.default_headers) + + import logging + logger = logging.getLogger(__name__) + logger.debug(f"header_params: {header_params}") if self.cookie: header_params["Cookie"] = self.cookie if header_params: From 06c72fc0e661fc9ceca3ed0b0353ba0ca9d37473 Mon Sep 17 00:00:00 2001 From: blaise-muhirwa Date: Tue, 2 Apr 2024 16:01:52 -0700 Subject: [PATCH 8/9] check that it's working --- generated/openapi_client/api_client.py | 4 ---- src/groundlight/internalapi.py | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/generated/openapi_client/api_client.py b/generated/openapi_client/api_client.py index af2de95d..b8909270 100644 --- a/generated/openapi_client/api_client.py +++ b/generated/openapi_client/api_client.py @@ -139,10 +139,6 @@ def __call_api( # header parameters header_params = header_params or {} header_params.update(self.default_headers) - - import logging - logger = logging.getLogger(__name__) - logger.debug(f"header_params: {header_params}") if self.cookie: header_params["Cookie"] = self.cookie if header_params: diff --git a/src/groundlight/internalapi.py b/src/groundlight/internalapi.py index 82b31423..b2b23052 100644 --- a/src/groundlight/internalapi.py +++ b/src/groundlight/internalapi.py @@ -205,6 +205,7 @@ def _headers(self) -> dict: # This metadata helps us debug issues with specific SDK versions. "x-sdk-version": get_version(), "x-sdk-language": "python", + "User-Agent": self.user_agent, } @RequestsRetryDecorator() From e4b979e6a121c608cb6333af836ecef78580c100 Mon Sep 17 00:00:00 2001 From: blaise-muhirwa Date: Tue, 2 Apr 2024 16:02:41 -0700 Subject: [PATCH 9/9] remove log lines --- src/groundlight/internalapi.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/groundlight/internalapi.py b/src/groundlight/internalapi.py index b2b23052..67b3acca 100644 --- a/src/groundlight/internalapi.py +++ b/src/groundlight/internalapi.py @@ -186,10 +186,6 @@ def call_api(self, *args, **kwargs): elif not header_param.get(self.REQUEST_ID_HEADER, None): header_param[self.REQUEST_ID_HEADER] = _generate_request_id() # Note that we have updated the actual dict in args, so we don't have to put it back in - - logger.info(f"Args: {args}") - logger.info(f"Kwargs: {kwargs}") - return super().call_api(*args, **kwargs) #