dabla commented on code in PR #62731:
URL: https://github.com/apache/airflow/pull/62731#discussion_r2905172292
##########
providers/openfaas/src/airflow/providers/openfaas/hooks/openfaas.py:
##########
@@ -106,7 +109,8 @@ def update_function(self, body: dict[str, Any]) -> None:
"""Update OpenFaaS function."""
url = self.get_conn().host + self.UPDATE_FUNCTION
self.log.info("Updating function %s", url)
- response = requests.put(url, body)
+ timeout = int(self.get_conn().extra_dejson.get("timeout", 60))
Review Comment:
I would still try to get the timeout from the connection extra if defined,
that way you can define a global timeout value on the connection level, but the
timeout parameter should be an instance field of the hook and should thus also
be configurable through the constructor of the hook which by default will be
None.
```
def __init__(self, function_name=None, conn_id: str =
"open_faas_default", timeout: int | None = None *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.function_name = function_name
self.conn_id = conn_id
self.timeout = timeout
```
Next to that, in the get_conn method, where the connection is being fetched,
I would check if timeout isn't defined in Hook, and if it's not defined, then I
would check in extra of connection or use the constant REQUEST_TIMEOUT defined
at the top level.
```
def get_conn(self):
conn = self.get_connection(self.conn_id)
if self.timeout is None:
self.timeout = conn.extra_dejson.get("timeout", REQUEST_TIMEOUT)
return conn
```
--
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]