Repository navigation
feat(kernel): expose HTTP/2 opt-out #1070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
657f2ff
c469dba
a977981
36af470
21cda69
ccb6cec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,6 +218,14 @@ def _kernel_session_accepts_kwarg(name: str) -> bool: | |
| return support.accepts_kwargs or name in support.parameters | ||
|
|
||
|
|
||
| def _kernel_http2_kwargs(value: Optional[bool]) -> Dict[str, bool]: | ||
| if value is None: | ||
| return {} | ||
| if not isinstance(value, bool): | ||
| raise ValueError("enable_http2 must be a bool") | ||
| return {"enable_http2": value} | ||
|
|
||
|
|
||
| def _kernel_geospatial_kwargs(value: bool) -> Dict[str, bool]: | ||
| """Build the explicit native geospatial-support kwarg. | ||
|
|
||
|
|
@@ -346,6 +354,7 @@ def __init__( | |
| # The kernel binding owns type and range validation. | ||
| self._request_timeout_secs = kwargs.get("request_timeout_secs") | ||
| self._max_connections = kwargs.get("max_connections") | ||
| self._http2_kwargs = _kernel_http2_kwargs(kwargs.get("enable_http2")) | ||
| self._use_cloud_fetch = kwargs.get("use_cloud_fetch", True) | ||
| self._max_download_threads = kwargs.get("max_download_threads", 16) | ||
| if ( | ||
|
|
@@ -538,6 +547,7 @@ def open_session( | |
| **geospatial_kwargs, | ||
| **max_connections_kwargs, | ||
| **http_headers_kwargs, | ||
| **self._http2_kwargs, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High — An explicit 🔀 Found by both reviewers · confirmed by the judge There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High — enable_http2 is passed to the native Session without _kernel_session_accepts_kwarg, unlike geospatial and max_connections. An older kernel wheel that lacks the parameter fails with a generic TypeError/DatabaseError. Gate it and raise NotSupportedError naming the required kernel version, and bump the pin once the matching kernel ships. 🔀 Found by both reviewers · confirmed by the judge |
||
| ) | ||
| except Exception as exc: | ||
| raise _wrap_kernel_exception("open_session", exc) from exc | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -407,6 +407,52 @@ def fake_session(**options): | |
| assert configuration == original | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("enabled", [None, True, False]) | ||
| def test_open_session_preserves_http2_option(monkeypatch, enabled): | ||
| captured = {} | ||
|
|
||
| def fake_session(**kwargs): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 Low — The new tests only check kwarg pass-through to a fake 🔀 Found by GPT-6.1 Terra · confirmed by the judge
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The shared kernel owns the TLS negotiation, opt-out and proxy tests; this adapter owns omitted/true/false forwarding. The matching PyO3 binding now also tests all three mappings in its existing HTTP-config helper. Actual source-built Python transport checks verify negotiated HTTP versions. These cover the distinct boundaries without duplicating the shared TLS suite in this repository. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still open at 21cda69: tests/ only has fake-Session forwarding tests (test_kernel_client.py:411-450). No real-wheel test shows the installed kernel accepts and honors enable_http2. |
||
| captured.update(kwargs) | ||
| session = MagicMock() | ||
| session.session_id = "sess-id" | ||
| return session | ||
|
|
||
| monkeypatch.setattr(kernel_client._kernel, "Session", fake_session) | ||
| client = kernel_client.KernelDatabricksClient( | ||
| server_hostname="example.cloud.databricks.com", | ||
| http_path="/sql/1.0/warehouses/abc", | ||
| auth_provider=AccessTokenAuthProvider("dapi-test"), | ||
| ssl_options=None, | ||
| **({"enable_http2": enabled} if enabled is not None else {}), | ||
| ) | ||
| client.open_session(session_configuration=None, catalog=None, schema=None) | ||
| if enabled is None: | ||
| assert "enable_http2" not in captured | ||
| else: | ||
| assert captured["enable_http2"] is enabled | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("value", ["false", 0, 1]) | ||
| def test_http2_option_rejects_non_boolean_through_connect(monkeypatch, value): | ||
| from databricks import sql | ||
|
|
||
| native_session = MagicMock() | ||
| auth_kwargs = MagicMock() | ||
| monkeypatch.setattr(kernel_client._kernel, "Session", native_session) | ||
| monkeypatch.setattr(kernel_client, "kernel_auth_kwargs", auth_kwargs) | ||
| with pytest.raises(ValueError, match="enable_http2 must be a bool"): | ||
| sql.connect( | ||
| server_hostname="example.cloud.databricks.com", | ||
| http_path="/sql/1.0/warehouses/abc", | ||
| access_token="dapi-test", | ||
| use_kernel=True, | ||
| enable_telemetry=False, | ||
| enable_http2=value, | ||
| ) | ||
| native_session.assert_not_called() | ||
| auth_kwargs.assert_not_called() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("timeout", [None, 0, 12.5]) | ||
| def test_open_session_passes_request_timeout_to_kernel(monkeypatch, timeout): | ||
| captured = {} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High —
_kernel_http2_kwargspasses an explicitenable_http2toSessionwithout calling_kernel_session_accepts_kwarg. An older kernel wheel then fails with a TypeError, which is wrapped into a vague OperationalError. Gate it like_kernel_geospatial_kwargsand raise NotSupportedError saying a newer databricks-sql-kernel is required.🔀 Found by both reviewers · confirmed by the judge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This driver release requires a matching kernel binding exposing Session(enable_http2=...). The dependency and blocked merge/release status are explicit in the PR description. Compatibility with an older kernel wheel is not part of this change; the coordinated release must integrate the matching native artifacts before this option ships.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still open at 21cda69: the pin is still
^1.4.0(pyproject.toml:73), and explicitenable_http2reachesSessionwithout the_kernel_session_accepts_kwargcheck (client.py:221-226).