wfork-streamlit-profiler 0.2.8rc5__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wfork_streamlit_profiler/__init__.py +22 -5
- {wfork_streamlit_profiler-0.2.8rc5.dist-info → wfork_streamlit_profiler-1.1.0.dist-info}/METADATA +15 -11
- wfork_streamlit_profiler-1.1.0.dist-info/RECORD +5 -0
- {wfork_streamlit_profiler-0.2.8rc5.dist-info → wfork_streamlit_profiler-1.1.0.dist-info}/WHEEL +1 -1
- wfork_streamlit_profiler-0.2.8rc5.dist-info/RECORD +0 -5
- {wfork_streamlit_profiler-0.2.8rc5.dist-info → wfork_streamlit_profiler-1.1.0.dist-info}/LICENSE +0 -0
@@ -1,16 +1,35 @@
|
|
1
1
|
import streamlit.components.v1 as components
|
2
2
|
from pyinstrument import Profiler as OriginalProfiler
|
3
|
+
from pyinstrument.profiler import AsyncMode
|
4
|
+
from pyinstrument.session import Session
|
3
5
|
|
4
6
|
|
5
7
|
class Profiler(OriginalProfiler):
|
6
|
-
|
8
|
+
_auto_output_on_stop: bool
|
9
|
+
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
interval: float = 0.001,
|
13
|
+
async_mode: AsyncMode = "enabled",
|
14
|
+
auto_output_on_stop: bool = True,
|
15
|
+
):
|
16
|
+
super().__init__(interval, async_mode)
|
17
|
+
self._auto_output_on_stop = auto_output_on_stop
|
18
|
+
|
19
|
+
def stop(self) -> Session:
|
7
20
|
session = super().stop()
|
8
|
-
|
21
|
+
|
22
|
+
if self._auto_output_on_stop:
|
23
|
+
self.output_streamlit()
|
24
|
+
|
25
|
+
return session
|
26
|
+
|
27
|
+
def output_streamlit(self) -> None:
|
9
28
|
# Create HTML report of profiling results.
|
10
29
|
html = self.output_html()
|
11
30
|
|
12
31
|
# Adapt style of html report to match Streamlit's design.
|
13
|
-
|
32
|
+
|
14
33
|
# Default colors for Streamlit's white theme.
|
15
34
|
# TODO: Use streamlit's theme colors instead of hardcoding colors. Doesn't work
|
16
35
|
# currently, see https://github.com/streamlit/streamlit/issues/4198.
|
@@ -80,5 +99,3 @@ class Profiler(OriginalProfiler):
|
|
80
99
|
|
81
100
|
# Display modified HTML report in iframe.
|
82
101
|
components.html(html, height=600)
|
83
|
-
|
84
|
-
return session
|
{wfork_streamlit_profiler-0.2.8rc5.dist-info → wfork_streamlit_profiler-1.1.0.dist-info}/METADATA
RENAMED
@@ -1,13 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: wfork-streamlit-profiler
|
3
|
-
Version:
|
3
|
+
Version: 1.1.0
|
4
4
|
Summary: (fork of) Runtime profiler for Streamlit, powered by pyinstrument
|
5
5
|
License: MIT
|
6
6
|
Author: Wyatt S Carpenter
|
7
|
-
Requires-Python: >=3.
|
7
|
+
Requires-Python: >=3.8,<4.0
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
10
|
-
Classifier: Programming Language :: Python :: 3.7
|
11
10
|
Classifier: Programming Language :: Python :: 3.8
|
12
11
|
Classifier: Programming Language :: Python :: 3.9
|
13
12
|
Classifier: Programming Language :: Python :: 3.10
|
@@ -32,8 +31,6 @@ helps you find out which parts of your app are slow. It profiles the code via
|
|
32
31
|
[pyinstrument](https://github.com/joerick/pyinstrument) and shows the results right
|
33
32
|
within your Streamlit app.
|
34
33
|
|
35
|
-
<sup>Alpha version, use with care.</sup>
|
36
|
-
|
37
34
|
---
|
38
35
|
|
39
36
|
<h3 align="center">
|
@@ -54,19 +51,24 @@ pip install wfork-streamlit-profiler
|
|
54
51
|
|
55
52
|
## Usage
|
56
53
|
|
57
|
-
```
|
54
|
+
```python3
|
58
55
|
import streamlit as st
|
59
56
|
from wfork_streamlit_profiler import Profiler
|
60
57
|
|
61
58
|
with Profiler():
|
62
59
|
st.title("My app")
|
63
60
|
# ... other code
|
61
|
+
```
|
62
|
+
|
63
|
+
Or:
|
64
|
+
```python3
|
65
|
+
import streamlit as st
|
66
|
+
from wfork_streamlit_profiler import Profiler
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
#
|
68
|
-
|
69
|
-
# p.stop()
|
68
|
+
p = Profiler()
|
69
|
+
p.start()
|
70
|
+
# ... other code
|
71
|
+
p.stop()
|
70
72
|
```
|
71
73
|
|
72
74
|
Then start your app as usual: `streamlit run my_app.py`
|
@@ -74,3 +76,5 @@ Then start your app as usual: `streamlit run my_app.py`
|
|
74
76
|
The `Profiler` class is an extension of `pyinstrument.Profiler`, so you can use
|
75
77
|
[all of its functions](https://pyinstrument.readthedocs.io/en/latest/reference.html#pyinstrument.Profiler).
|
76
78
|
|
79
|
+
Don't want the profiler to immediately display when you stop profiling? Initialize it with `Profiler(auto_output_on_stop=False)` instead, and call the `.output_streamlit()` method whenever you want it to display, instead. You can also set the async_mode of the profiler in the pyinstrument in the same constructor, whatever that means.
|
80
|
+
|
@@ -0,0 +1,5 @@
|
|
1
|
+
wfork_streamlit_profiler/__init__.py,sha256=0pmPDhxnxIGuxbGbwfyTrXDHBeL8vp33n9SpGwwOyfk,3983
|
2
|
+
wfork_streamlit_profiler-1.1.0.dist-info/LICENSE,sha256=Y9ej8y1BLFQZSAREXkrHmDgA0M35msgF8d6D9KoFf5c,1071
|
3
|
+
wfork_streamlit_profiler-1.1.0.dist-info/METADATA,sha256=WKk-CC-15FRrN79TktsgvJXc91Nwj3Pj7BEB73DWt8k,2873
|
4
|
+
wfork_streamlit_profiler-1.1.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
5
|
+
wfork_streamlit_profiler-1.1.0.dist-info/RECORD,,
|
@@ -1,5 +0,0 @@
|
|
1
|
-
wfork_streamlit_profiler/__init__.py,sha256=LVSu6yccrR7AYARUDZmk2R9gQlvEnOR_zbgq_jH6iKQ,3503
|
2
|
-
wfork_streamlit_profiler-0.2.8rc5.dist-info/LICENSE,sha256=Y9ej8y1BLFQZSAREXkrHmDgA0M35msgF8d6D9KoFf5c,1071
|
3
|
-
wfork_streamlit_profiler-0.2.8rc5.dist-info/METADATA,sha256=S59RGmgh6wz_cuZz9q_wR9fbK467C2b1TBOFSK30sZE,2542
|
4
|
-
wfork_streamlit_profiler-0.2.8rc5.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
5
|
-
wfork_streamlit_profiler-0.2.8rc5.dist-info/RECORD,,
|
{wfork_streamlit_profiler-0.2.8rc5.dist-info → wfork_streamlit_profiler-1.1.0.dist-info}/LICENSE
RENAMED
File without changes
|