You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/06/01 20:34:19 UTC
(superset) branch master updated: chore(deps-dev): bump pyinstrument from 4.4.0 to 5.1.2 (#40377)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 1523d797ca6 chore(deps-dev): bump pyinstrument from 4.4.0 to 5.1.2 (#40377)
1523d797ca6 is described below
commit 1523d797ca69e3a70aa8b0ea470ba30a6ad5bb95
Author: dependabot[bot] <49...@users.noreply.github.com>
AuthorDate: Mon Jun 1 13:34:12 2026 -0700
chore(deps-dev): bump pyinstrument from 4.4.0 to 5.1.2 (#40377)
Signed-off-by: dependabot[bot] <su...@github.com>
Co-authored-by: dependabot[bot] <49...@users.noreply.github.com>
Co-authored-by: Claude Code <no...@anthropic.com>
Co-authored-by: Evan <ev...@preset.io>
---
pyproject.toml | 2 +-
requirements/development.txt | 2 +-
tests/unit_tests/utils/profiler_test.py | 74 +++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 92dca6a5fdd..38dbe8508e7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -225,7 +225,7 @@ development = [
"progress>=1.5,<2",
"psutil",
"pyfakefs",
- "pyinstrument>=4.0.2,<6",
+ "pyinstrument>=5.1.2,<6",
"pylint",
"pytest<8.0.0", # hairy issue with pytest >=8 where current_app proxies are not set in time
"pytest-asyncio",
diff --git a/requirements/development.txt b/requirements/development.txt
index edac723c51c..bfade642b4a 100644
--- a/requirements/development.txt
+++ b/requirements/development.txt
@@ -768,7 +768,7 @@ pygments==2.20.0
# rich
pyhive==0.7.0
# via apache-superset
-pyinstrument==4.4.0
+pyinstrument==5.1.2
# via apache-superset
pyjwt==2.12.0
# via
diff --git a/tests/unit_tests/utils/profiler_test.py b/tests/unit_tests/utils/profiler_test.py
new file mode 100644
index 00000000000..cbd21147db1
--- /dev/null
+++ b/tests/unit_tests/utils/profiler_test.py
@@ -0,0 +1,74 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from typing import Any, Callable
+
+import pytest
+from pytest_mock import MockerFixture
+from werkzeug.test import Client
+
+from superset.utils.profiler import SupersetProfiler
+
+
+def simple_app(
+ environ: dict[str, Any], start_response: Callable[..., Any]
+) -> list[bytes]:
+ """A trivial WSGI app used as the wrapped application under test."""
+ start_response("200 OK", [("Content-Type", "text/plain")])
+ return [b"hello world"]
+
+
+def test_profiler_passthrough_without_instrument_flag() -> None:
+ """
+ Without ``?_instrument=1`` the middleware must transparently return the
+ wrapped app's response and not invoke pyinstrument at all.
+ """
+ client = Client(SupersetProfiler(simple_app))
+ response = client.get("/")
+
+ assert response.status_code == 200
+ assert response.data == b"hello world"
+
+
+def test_profiler_returns_html_when_instrumented() -> None:
+ """
+ With ``?_instrument=1`` the middleware profiles the wrapped call and
+ returns an HTML report. This exercises the three pyinstrument API
+ surfaces ``SupersetProfiler`` depends on -- ``Profiler(interval=...)``,
+ the context-manager protocol, and ``output_html()`` -- so a breaking
+ change in any of them (e.g. across a major pyinstrument bump) fails here
+ instead of silently breaking the profiling endpoint in production.
+ """
+ client = Client(SupersetProfiler(simple_app, interval=0.001))
+ response = client.get("/?_instrument=1")
+
+ assert response.status_code == 200
+ assert response.mimetype == "text/html"
+ body = response.data.decode("utf-8").lower()
+ # pyinstrument's HTML renderer emits a full HTML document.
+ assert "<html" in body
+
+
+def test_profiler_raises_when_pyinstrument_missing(mocker: MockerFixture) -> None:
+ """
+ When pyinstrument is not installed the instrumented path must fail loudly
+ rather than silently skip profiling.
+ """
+ mocker.patch("superset.utils.profiler.Profiler", None)
+ client = Client(SupersetProfiler(simple_app))
+
+ with pytest.raises(Exception, match="pyinstrument is not installed"):
+ client.get("/?_instrument=1")