Skip to content

Commit

Permalink
Set authenticated in constructor instead
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbern committed Oct 18, 2024
1 parent 63f3661 commit 74ecd4d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modal/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 74ecd4d

Please sign in to comment.