Skip to content

Commit

Permalink
Fix undefined variable if get_profile_observatory_link() fails (#1590)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
richard-rogers authored Nov 18, 2024
1 parent 091896d commit 301453c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python/whylogs/api/whylabs/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 301453c

Please sign in to comment.