Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/groundlight/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ def __init__(
self.image_queries_api = ImageQueriesApi(self.api_client)
self.user_api = UserApi(self.api_client)
self.labels_api = LabelsApi(self.api_client)
self.logged_in_user = "(not-logged-in)"
self._verify_connectivity()

def __repr__(self) -> str:
return f"Logged in as {self.whoami()} to Groundlight at {self.endpoint}"
# Don't call the API here because that can get us stuck in a loop rendering exception strings
return f"Logged in as {self.logged_in_user} to Groundlight at {self.endpoint}"

def _verify_connectivity(self) -> None:
"""
Expand All @@ -166,7 +168,7 @@ def _verify_connectivity(self) -> None:
"""
try:
# a simple query to confirm that the endpoint & API token are working
self.whoami()
self.logged_in_user = self.whoami()
if self._user_is_privileged():
logger.warning(
"WARNING: The current user has elevated permissions. Please verify such permissions are necessary"
Expand Down Expand Up @@ -204,7 +206,7 @@ def whoami(self) -> str:

:return: str
"""
obj = self.user_api.who_am_i()
obj = self.user_api.who_am_i(_request_timeout=DEFAULT_REQUEST_TIMEOUT)
return obj["email"]

def _user_is_privileged(self) -> bool:
Expand Down
Loading