From 301453cdf08f7800f3f2d16fd529f4f886058f2d Mon Sep 17 00:00:00 2001 From: richard-rogers <93153899+richard-rogers@users.noreply.github.com> Date: Mon, 18 Nov 2024 03:38:24 +0000 Subject: [PATCH] Fix undefined variable if get_profile_observatory_link() fails (#1590) Bail out early if `get_profile_observatory_link()` fails since the rest of the methods require a valid `response`. - [ ] I have reviewed the [Guidelines for Contributing](CONTRIBUTING.md) and the [Code of Conduct](CODE_OF_CONDUCT.md). --- python/whylogs/api/whylabs/session/session.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/whylogs/api/whylabs/session/session.py b/python/whylogs/api/whylabs/session/session.py index 5ff8bdb8c..42a2b5f88 100644 --- a/python/whylogs/api/whylabs/session/session.py +++ b/python/whylogs/api/whylabs/session/session.py @@ -292,9 +292,13 @@ def upload_reference_profiles(self, profile_aliases: Dict[str, ResultSet]) -> Un org_id = self.config.require_org_id() dataset_id = self.config.require_default_dataset_id() - response: GetProfileObservatoryLinkResponse = self._whylabs_log_api.value.get_profile_observatory_link( - dataset_id, org_id, request - ) + try: + response: GetProfileObservatoryLinkResponse = self._whylabs_log_api.value.get_profile_observatory_link( + dataset_id, org_id, request + ) + except Exception as e: + logger.info(f"Convenience profile links could not be generated for the sucessfully uploading profiles: {e}") + return NotSupported() return UploadResult( viewing_url=response.observatory_url, @@ -331,6 +335,7 @@ def upload_batch_profile(self, profile: ResultSet) -> Union[UploadResult, NotSup ) except Exception as e: logger.info(f"Convenience profile links could not be generated for the sucessfully uploading profiles: {e}") + return NotSupported() profile_url = response.observatory_url if response else "" individual_urls = response.individual_observatory_urls if response else None