Skip to content

Commit

Permalink
Allow authenticator parameter when connecting to snowflake (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
pappacena authored Oct 31, 2024
1 parent 1f9f3bc commit d7a12ba
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions landingai/predict/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(
snowflake_user: str,
snowflake_password: Optional[str] = None,
snowflake_private_key: Optional[str] = None,
snowflake_authenticator: Optional[str] = None,
native_app_url: str,
# TODO: Remove this once we remove the API key auth from snowflake
api_key: Optional[str] = None,
Expand All @@ -40,6 +41,7 @@ def __init__(
self.snowflake_user = snowflake_user
self.snowflake_password = snowflake_password
self.snowflake_private_key = snowflake_private_key
self.snowflake_authenticator = snowflake_authenticator

self._auth_token = None
self._last_auth_token_fetch: Optional[datetime.datetime] = None
Expand Down Expand Up @@ -86,6 +88,8 @@ def _get_auth_token(self) -> str:
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption(),
)
if self.snowflake_authenticator is not None:
connect_params["authenticator"] = self.snowflake_authenticator

ctx = snowflake.connector.connect(**connect_params)
ctx._all_async_queries_finished = lambda: False # type: ignore
Expand Down

0 comments on commit d7a12ba

Please sign in to comment.