You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org> on 2024/11/23 10:07:48 UTC
[PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
jieyao-MilestoneHub opened a new pull request, #44302:
URL: https://github.com/apache/airflow/pull/44302
This PR adds an `adapter` parameter to the `HttpHook`, allowing users to mount custom adapters for HTTP request handling. This enhances flexibility and supports use cases like custom retries, timeouts, and SSL handling.
### Summary of Changes:
- Added `adapter` parameter to `HttpHook` to allow custom HTTP adapters.
- Modified `get_conn` to support mounting custom adapters or using TCPKeepAliveAdapter by default.
- Added comprehensive tests to validate the functionality of the `adapter` parameter and its integration with `get_conn`.
- Ensured all new tests pass and maintain compatibility with existing functionality.
### Issue Reference:
Closes #44285
### Testing and Validation:
- Added unit tests in `~/providers/tests/http/hooks/test_http.py` to validate:
- Mounting custom adapters.
- Default behavior when no adapter is provided.
- Handling invalid adapter types.
- Ran `pytest providers/tests/http/hooks/test_http.py` using breeze.
- Pass `pre-commit run --files providers/src/airflow/providers/http/hooks/http.py providers/tests/http/hooks/test_http.py` using breeze.
### Backward Compatibility:
This change is backward-compatible. The new `adapter` parameter is optional and defaults to None, preserving existing behavior.
<!--
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.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1860249856
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
The main concern is https://github.com/apache/airflow/pull/44302#discussion_r1860249178
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1858732936
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
Based on the principle of not exposing session members in get_conn, we might add an additional function like:
```python
def _configure_session_from_auth(self, session: requests.Session, connection: Connection) -> None:
session.auth = self._extract_auth(connection)
return session
```
However, I eventually decided to stick with the original version. Is there any issue with this approach?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2513963191
Thank you all for taking the time to work on this together! 😊
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1860900460
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
Got it, thank you for your suggestion! I've made the changes accordingly.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2513892913
Thanks @jieyao-MilestoneHub ! The PR looks LGTM! I'll keep it for one or two days for folks to check. Please ping me if I forget to get back to you and merge it.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1856448041
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,64 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
-
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
+ self._mount_adapters(session)
+
return session
+ def _set_base_url(self, connection) -> None:
+ if connection.host and "://" in connection.host:
+ self.base_url = connection.host
+ else:
+ schema = connection.schema or "http"
+ host = connection.host or ""
+ self.base_url = f"{schema}://{host}"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
+
+ def _set_extra(self, session: requests.Session, connection) -> None:
+ if connection.extra:
+ extra = connection.extra_dejson
+ extra.pop("timeout", None)
+ extra.pop("allow_redirects", None)
+ session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
+ session.stream = extra.pop("stream", False)
+ session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
+ session.cert = extra.pop("cert", None)
+ session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
+ session.trust_env = extra.pop("trust_env", True)
+
+ try:
+ session.headers.update(extra)
+ except TypeError:
+ self.log.warning("Connection to %s has invalid extra field.", connection.host)
+
+ def _mount_adapters(self, session: requests.Session) -> None:
+ if self.adapter:
+ scheme = urlparse(self.base_url).scheme or "https"
+ session.mount(f"{scheme}://", self.adapter)
+ elif self.keep_alive_adapter:
+ session.mount("http://", self.keep_alive_adapter)
+ session.mount("https://", self.keep_alive_adapter)
Review Comment:
Thank you for your insight. The reasoning behind this implementation is to account for custom cases where the schema might be empty. However, this does seem to tie back to _set_base_url. I’ll make adjustments accordingly. Appreciate you pointing this out!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1856035039
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -83,11 +87,25 @@ def __init__(
self.base_url: str = ""
self._retry_obj: Callable[..., Any]
self._auth_type: Any = auth_type
+
+ if adapter is not None and not isinstance(adapter, BaseAdapter):
+ raise TypeError("adapter must be an instance of requests.adapters.BaseAdapter")
+ self.adapter = adapter
+
self.tcp_keep_alive = tcp_keep_alive
self.keep_alive_idle = tcp_keep_alive_idle
self.keep_alive_count = tcp_keep_alive_count
self.keep_alive_interval = tcp_keep_alive_interval
+ if self.tcp_keep_alive:
+ self.keep_alive_adapter = TCPKeepAliveAdapter(
+ idle=self.keep_alive_idle,
+ count=self.keep_alive_count,
+ interval=self.keep_alive_interval,
+ )
+ else:
+ self.keep_alive_adapter = None
Review Comment:
Ah just moved.
This doesn't make any network requests by creating it here does it?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2508812379
I need some time to figure out how to fix this issue.:)
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2513430007
Thanks for your suggestion!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2515285992
> Thank you all for taking the time to work on this together! 😊
Thank you for your great first contribution :)
Looking forward!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1855179671
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -72,6 +74,7 @@ def __init__(
method: str = "POST",
http_conn_id: str = default_conn_name,
auth_type: Any = None,
+ adapter: BaseAdapter | None = None,
Review Comment:
Please add an appropriate docstring in the section above
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -143,6 +151,18 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
if headers:
session.headers.update(headers)
+ if self.adapter:
+ scheme = urlparse(self.base_url).scheme if self.base_url else "https"
+ session.mount(f"{scheme}://", self.adapter)
+ elif self.tcp_keep_alive:
+ keep_alive_adapter = TCPKeepAliveAdapter(
+ idle=self.keep_alive_idle,
+ count=self.keep_alive_count,
+ interval=self.keep_alive_interval,
+ )
+ session.mount("http://", keep_alive_adapter)
+ session.mount("https://", keep_alive_adapter)
Review Comment:
We do we need to instantiate `TCPKeepAliveAdapter` here if we already have it in the `run` method?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1860245080
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
Review Comment:
got it. sounds good! Thanks for the explanation!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "kiaradlf (via GitHub)" <gi...@apache.org>.
kiaradlf commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1856146909
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -83,11 +87,25 @@ def __init__(
self.base_url: str = ""
self._retry_obj: Callable[..., Any]
self._auth_type: Any = auth_type
+
+ if adapter is not None and not isinstance(adapter, BaseAdapter):
+ raise TypeError("adapter must be an instance of requests.adapters.BaseAdapter")
+ self.adapter = adapter
+
self.tcp_keep_alive = tcp_keep_alive
self.keep_alive_idle = tcp_keep_alive_idle
self.keep_alive_count = tcp_keep_alive_count
self.keep_alive_interval = tcp_keep_alive_interval
+ if self.tcp_keep_alive:
+ self.keep_alive_adapter = TCPKeepAliveAdapter(
+ idle=self.keep_alive_idle,
+ count=self.keep_alive_count,
+ interval=self.keep_alive_interval,
+ )
+ else:
+ self.keep_alive_adapter = None
Review Comment:
it doesn't, adapters just modify how actual requests are handled
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #44302:
URL: https://github.com/apache/airflow/pull/44302
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2495425712
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-pre-commit-hooks) will help you with that.
- In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://s.apache.org/airflow-slack
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1856031525
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,64 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
-
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
+ self._mount_adapters(session)
+
return session
+ def _set_base_url(self, connection) -> None:
+ if connection.host and "://" in connection.host:
+ self.base_url = connection.host
+ else:
+ schema = connection.schema or "http"
+ host = connection.host or ""
+ self.base_url = f"{schema}://{host}"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
+
+ def _set_extra(self, session: requests.Session, connection) -> None:
+ if connection.extra:
+ extra = connection.extra_dejson
+ extra.pop("timeout", None)
+ extra.pop("allow_redirects", None)
+ session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
+ session.stream = extra.pop("stream", False)
+ session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
+ session.cert = extra.pop("cert", None)
+ session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
+ session.trust_env = extra.pop("trust_env", True)
+
+ try:
+ session.headers.update(extra)
+ except TypeError:
+ self.log.warning("Connection to %s has invalid extra field.", connection.host)
+
+ def _mount_adapters(self, session: requests.Session) -> None:
+ if self.adapter:
+ scheme = urlparse(self.base_url).scheme or "https"
+ session.mount(f"{scheme}://", self.adapter)
+ elif self.keep_alive_adapter:
+ session.mount("http://", self.keep_alive_adapter)
+ session.mount("https://", self.keep_alive_adapter)
Review Comment:
Why do we parse the scheme in one branch but hardcode http+https in the other?
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -83,11 +87,25 @@ def __init__(
self.base_url: str = ""
self._retry_obj: Callable[..., Any]
self._auth_type: Any = auth_type
+
+ if adapter is not None and not isinstance(adapter, BaseAdapter):
+ raise TypeError("adapter must be an instance of requests.adapters.BaseAdapter")
+ self.adapter = adapter
+
self.tcp_keep_alive = tcp_keep_alive
self.keep_alive_idle = tcp_keep_alive_idle
self.keep_alive_count = tcp_keep_alive_count
self.keep_alive_interval = tcp_keep_alive_interval
+ if self.tcp_keep_alive:
+ self.keep_alive_adapter = TCPKeepAliveAdapter(
+ idle=self.keep_alive_idle,
+ count=self.keep_alive_count,
+ interval=self.keep_alive_interval,
+ )
+ else:
+ self.keep_alive_adapter = None
Review Comment:
What's this all about?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1861620321
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
Review Comment:
and this
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
+
+ def _set_extra(self, session: requests.Session, connection) -> None:
+ if connection.extra:
+ extra = connection.extra_dejson
+ extra.pop("timeout", None)
+ extra.pop("allow_redirects", None)
+ session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
+ session.stream = extra.pop("stream", False)
+ session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
+ session.cert = extra.pop("cert", None)
+ session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
+ session.trust_env = extra.pop("trust_env", True)
+
+ try:
+ session.headers.update(extra)
+ except TypeError:
+ self.log.warning("Connection to %s has invalid extra field.", connection.host)
+
+ def _mount_adapters(self, session: requests.Session) -> None:
+ scheme = urlparse(self.base_url).scheme
+ if not scheme:
+ raise ValueError("Cannot mount adapters: base_url must include a valid scheme (http or https).")
Review Comment:
would be nice if we could also address this 🙂
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1858682365
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
The main reason I wrote it this way was for consistency, as the nearby functions also make modifications internally.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1860249178
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
Yes, the main reason is that it's not as intuitive. It's much easier to understand if it's change a value in instance level (i.e., `self. = ...`) or returning a value and assigning it back to something
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2512667471
> running `pre-commit run --all-files` locally can help you resolve issues earlier 🙂
Or `breeze static-checks --only-my-changes` which runs only on files you changed so it is way faster.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2495473186
Thank you, @shahar1, for your detailed review and valuable feedback! I’ve addressed your comments by:
1. Adding a detailed docstring for the `__init__` method, including the missing `adapter` parameter.
2. Removing the redundant instantiation of `TCPKeepAliveAdapter` in the `run` method.
Please let me know if there’s anything else I can improve. I really appreciate your time and support!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2495887393
Sure, let's have someone else take a look. Thank you for your suggestion!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1858627534
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
Review Comment:
If :// is present in the host string, it indicates the presence of a scheme component, and the string can be considered a complete URL as defined by [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986.html#section-3).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1860250519
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
The example you provide actually looks good to me
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1861427665
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -76,18 +79,33 @@ def __init__(
tcp_keep_alive_idle: int = 120,
tcp_keep_alive_count: int = 20,
tcp_keep_alive_interval: int = 30,
+ adapter: HTTPAdapter | None = None,
) -> None:
super().__init__()
self.http_conn_id = http_conn_id
self.method = method.upper()
self.base_url: str = ""
self._retry_obj: Callable[..., Any]
self._auth_type: Any = auth_type
+
+ if adapter is not None and not isinstance(adapter, HTTPAdapter):
Review Comment:
```suggestion
if not isinstance(adapter, HTTPAdapter):
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2507614108
Tests currently seem to fail :(
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2511254028
running `pre-commit run --all-files` locally can help you resolve issues earlier 🙂
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2514188597
Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1867277912
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,47 +113,76 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
-
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
-
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
+ connection = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ session = self._configure_session_from_auth(session, connection)
+ if connection.extra:
+ session = self._configure_session_from_extra(session, connection)
+ session = self._configure_session_from_mount_adapters(session)
if headers:
session.headers.update(headers)
+ return session
+
+ def _set_base_url(self, connection: Connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ # RFC 3986 (https://www.rfc-editor.org/rfc/rfc3986.html#page-16)
Review Comment:
This is nice!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1857883338
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
Review Comment:
```suggestion
def _set_auth(self, session: requests.Session, connection: Connection) -> None:
```
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -72,6 +75,7 @@ def __init__(
method: str = "POST",
http_conn_id: str = default_conn_name,
auth_type: Any = None,
+ adapter: HTTPAdapter | None = None,
Review Comment:
We should move this one to the last parameter or make it a keyword only argument. Otherwise, it would be a breaking change. I would suggest making it a keyword only argument
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
+
+ def _set_extra(self, session: requests.Session, connection) -> None:
+ if connection.extra:
Review Comment:
We should probably do this `if` check in `get_conn` instead
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
+
+ def _set_extra(self, session: requests.Session, connection) -> None:
Review Comment:
```suggestion
def _set_extra(self, session: requests.Session, connection: Connection) -> None:
```
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
Review Comment:
```suggestion
def _set_base_url(self, connection: Connection) -> None:
```
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
Review Comment:
```suggestion
self.base_url = f"{self.base_url}:{connection.port}"
```
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
```suggestion
def _extract_auth(self, connection: Connection) -> Any | None:
if connection.login:
return self.auth_type(connection.login, connection.password)
elif self._auth_type:
return self.auth_type()
```
or this might also work
if
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
Setting `session` this way would work. But it might confuse some contributors as we're changing the argument. I might suggest reason the `session` object and reassign it in `get_conn` instead.
something like `session = self._set_auth(...)`
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
Review Comment:
```suggestion
if connection.port:
self.base_url += f":{connection.port}"
```
I think it should be dedented 🤔 Could you please check whether I'm mistaken? If I'm not, would be better if we could add one unit test to cover it
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
+
+ def _set_extra(self, session: requests.Session, connection) -> None:
Review Comment:
`_set_extra` is a confusing name in this case as we're not actually setting extra but extracting attributes from extra
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
+
+ def _set_extra(self, session: requests.Session, connection) -> None:
+ if connection.extra:
+ extra = connection.extra_dejson
+ extra.pop("timeout", None)
+ extra.pop("allow_redirects", None)
+ session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
+ session.stream = extra.pop("stream", False)
+ session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
+ session.cert = extra.pop("cert", None)
+ session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
+ session.trust_env = extra.pop("trust_env", True)
+
+ try:
+ session.headers.update(extra)
+ except TypeError:
+ self.log.warning("Connection to %s has invalid extra field.", connection.host)
+
+ def _mount_adapters(self, session: requests.Session) -> None:
+ scheme = urlparse(self.base_url).scheme
+ if not scheme:
+ raise ValueError("Cannot mount adapters: base_url must include a valid scheme (http or https).")
Review Comment:
```suggestion
raise ValueError(f"Cannot mount adapters: "{self.base_url}" does not include a valid scheme (http or https).")
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2495512067
> Thank you, @shahar1, for your detailed review and valuable feedback! I’ve addressed your comments by:
>
> 1. Adding a detailed docstring for the `__init__` method, including the missing `adapter` parameter.
> 2. Removing the redundant instantiation of `TCPKeepAliveAdapter` in the `run` method.
>
> Please let me know if there’s anything else I can improve. I really appreciate your time and support!
Thanks :) Regarding the 2nd point - could you please explain why it makes sense to relocate the instanation of `TCPKeepAliveAdapter` to the `__init__`?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on PR #44302:
URL: https://github.com/apache/airflow/pull/44302#issuecomment-2495766805
Thanks for the great suggestion! Moving the TCPKeepAliveAdapter to __init__ indeed streamlines the logic—keeps get_conn focused on session setup while ensuring TCP settings are ready upfront. A cleaner and more organized approach, much appreciated! 🙌
In response to the above, I've implemented two changes in this PR:
1. Moved the instantiation of TCPKeepAliveAdapter to __init__ for better organization and to keep get_conn focused on session setup.
2. Streamlined the handling of connection extras to make the session configuration more robust and easier to maintain.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Providers/HTTP] Add adapter parameter to HttpHook to allow custom requests adapters [airflow]
Posted by "jieyao-MilestoneHub (via GitHub)" <gi...@apache.org>.
jieyao-MilestoneHub commented on code in PR #44302:
URL: https://github.com/apache/airflow/pull/44302#discussion_r1858685047
##########
providers/src/airflow/providers/http/hooks/http.py:
##########
@@ -102,49 +120,68 @@ def get_conn(self, headers: dict[Any, Any] | None = None) -> requests.Session:
"""
Create a Requests HTTP session.
- :param headers: additional headers to be passed through as a dictionary
+ :param headers: Additional headers to be passed through as a dictionary.
+ :return: A configured requests.Session object.
"""
session = requests.Session()
+ connection = self.get_connection(self.http_conn_id)
- if self.http_conn_id:
- conn = self.get_connection(self.http_conn_id)
+ self._set_base_url(connection)
+ self._set_auth(session, connection)
+ self._set_extra(session, connection)
+ self._mount_adapters(session)
- if conn.host and "://" in conn.host:
- self.base_url = conn.host
- else:
- # schema defaults to HTTP
- schema = conn.schema if conn.schema else "http"
- host = conn.host if conn.host else ""
- self.base_url = f"{schema}://{host}"
-
- if conn.port:
- self.base_url += f":{conn.port}"
- if conn.login:
- session.auth = self.auth_type(conn.login, conn.password)
- elif self._auth_type:
- session.auth = self.auth_type()
- if conn.extra:
- extra = conn.extra_dejson
- extra.pop(
- "timeout", None
- ) # ignore this as timeout is only accepted in request method of Session
- extra.pop("allow_redirects", None) # ignore this as only max_redirects is accepted in Session
- session.proxies = extra.pop("proxies", extra.pop("proxy", {}))
- session.stream = extra.pop("stream", False)
- session.verify = extra.pop("verify", extra.pop("verify_ssl", True))
- session.cert = extra.pop("cert", None)
- session.max_redirects = extra.pop("max_redirects", DEFAULT_REDIRECT_LIMIT)
- session.trust_env = extra.pop("trust_env", True)
-
- try:
- session.headers.update(extra)
- except TypeError:
- self.log.warning("Connection to %s has invalid extra field.", conn.host)
if headers:
session.headers.update(headers)
return session
+ def _set_base_url(self, connection) -> None:
+ host = connection.host or ""
+ schema = connection.schema or "http"
+ if "://" in host:
+ self.base_url = host
+ else:
+ self.base_url = f"{schema}://{host}" if host else f"{schema}://"
+ if connection.port:
+ self.base_url += f":{connection.port}"
+ parsed = urlparse(self.base_url)
+ if not parsed.scheme:
+ raise ValueError(f"Invalid base URL: Missing scheme in {self.base_url}")
+
+ def _set_auth(self, session: requests.Session, connection) -> None:
+ if connection.login:
+ session.auth = self.auth_type(connection.login, connection.password)
+ elif self._auth_type:
+ session.auth = self.auth_type()
Review Comment:
Could you share your thoughts on the reasoning outlined above?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org