From 74ecd4d758f31092260da5c514f3537572a939eb Mon Sep 17 00:00:00 2001 From: Erik Bernhardsson Date: Fri, 18 Oct 2024 20:20:12 +0000 Subject: [PATCH] Set authenticated in constructor instead --- modal/client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modal/client.py b/modal/client.py index 370d1bc29e..8405606368 100644 --- a/modal/client.py +++ b/modal/client.py @@ -100,6 +100,7 @@ class _Client: _cancellation_context: TaskContext _cancellation_context_event_loop: asyncio.AbstractEventLoop = None _stub: Optional[api_grpc.ModalClientStub] + _credentials: Optional[Tuple[str, str]] def __init__( self, @@ -115,7 +116,6 @@ def __init__( self.client_type = client_type self._credentials = credentials self.version = version - self._authenticated = False self._closed = False self._channel: Optional[grpclib.client.Channel] = None self._stub: Optional[modal_api_grpc.ModalClientModal] = None @@ -127,7 +127,7 @@ def is_closed(self) -> bool: @property def authenticated(self): - return self._authenticated + return self._credentials is not None @property def stub(self) -> modal_api_grpc.ModalClientModal: @@ -174,7 +174,6 @@ async def _hello(self): if resp.warning: ALARM_EMOJI = chr(0x1F6A8) warnings.warn(f"{ALARM_EMOJI} {resp.warning} {ALARM_EMOJI}", DeprecationError) - self._authenticated = True except GRPCError as exc: if exc.status == Status.FAILED_PRECONDITION: raise VersionError(