justinpakzad commented on code in PR #68942: URL: https://github.com/apache/airflow/pull/68942#discussion_r3502028868
########## providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake_cortex_agent.py: ########## @@ -0,0 +1,167 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +from typing import Any + +import requests + +from airflow.providers.snowflake.hooks.snowflake import SnowflakeHook + +AGENT_REQUEST_TIMEOUT = 60 # Prevent hanging agent requests. + + +class SnowflakeCortexAgentHook(SnowflakeHook): + """Hook for interacting with Snowflake Cortex Agents.""" + + def _get_base_url(self) -> str: + conn_config = self._get_static_conn_params + + host = conn_config.get("host") + if host: + return f"https://{host}" + + return f"https://{conn_config['account']}.snowflakecomputing.com" + + def _get_access_token(self) -> str: + conn_config = self._get_conn_params() + + token = conn_config.get("token") + if not token: + raise ValueError( + "Snowflake connection does not provide an OAuth access token. " + "Cortex Agents require OAuth authentication." + ) Review Comment: I think the error message here is a bit misleading here as Cortex Agents do not strictly require OAuth. You can authenticate with key-pair or PATs as well. Maybe worth considering support for key-pair at some point. It's a pretty common auth method and would make this more accessible in my opinion. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
