hiplot-mm 0.0.2__py3-none-any.whl → 0.0.3rc1__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.
- hiplot/__init__.py +1 -1
- hiplot/fetchers.py +1 -1
- hiplot/fetchers_demo.py +2 -2
- hiplot/ipython.py +40 -8
- hiplot/pkginfo.py +11 -2
- hiplot/render.py +2 -2
- hiplot/server.py +9 -3
- hiplot/static/built/hiplot.bundle.js +1 -1
- hiplot/static/built/streamlit_component/hiplot_streamlit.bundle.js +1 -1
- hiplot/streamlit_helpers.py +11 -2
- hiplot/test_render.py +2 -2
- hiplot_mm-0.0.3rc1.dist-info/METADATA +174 -0
- hiplot_mm-0.0.3rc1.dist-info/RECORD +33 -0
- {hiplot_mm-0.0.2.dist-info → hiplot_mm-0.0.3rc1.dist-info}/WHEEL +1 -1
- {hiplot_mm-0.0.2.dist-info → hiplot_mm-0.0.3rc1.dist-info}/entry_points.txt +1 -2
- hiplot/static/built/component.d.ts +0 -109
- hiplot/static/built/component.js +0 -528
- hiplot/static/built/contextmenu.d.ts +0 -26
- hiplot/static/built/contextmenu.js +0 -90
- hiplot/static/built/controls.d.ts +0 -52
- hiplot/static/built/controls.js +0 -163
- hiplot/static/built/filters.d.ts +0 -21
- hiplot/static/built/filters.js +0 -96
- hiplot/static/built/header.d.ts +0 -39
- hiplot/static/built/header.js +0 -176
- hiplot/static/built/hiplot-mm-0.0.0.tar.gz +0 -0
- hiplot/static/built/hiplot.bundle.js.LICENSE.txt +0 -88
- hiplot/static/built/hiplot.bundle.js.map +0 -1
- hiplot/static/built/hiplot.d.ts +0 -8
- hiplot/static/built/hiplot.js +0 -14
- hiplot/static/built/hiplot.lib.js +0 -57712
- hiplot/static/built/hiplot.lib.js.map +0 -1
- hiplot/static/built/hiplot.licenses.txt +0 -682
- hiplot/static/built/hiplot_mm-0.0.0-py3-none-any.whl +0 -0
- hiplot/static/built/hiplot_streamlit.bundle.js +0 -3
- hiplot/static/built/hiplot_streamlit.bundle.js.LICENSE.txt +0 -97
- hiplot/static/built/hiplot_streamlit.bundle.js.map +0 -1
- hiplot/static/built/hiplot_streamlit.d.ts +0 -1
- hiplot/static/built/hiplot_streamlit.js +0 -85
- hiplot/static/built/hiplot_streamlit.licenses.txt +0 -689
- hiplot/static/built/hiplot_test.bundle.js +0 -3
- hiplot/static/built/hiplot_test.bundle.js.LICENSE.txt +0 -88
- hiplot/static/built/hiplot_test.bundle.js.map +0 -1
- hiplot/static/built/hiplot_test.d.ts +0 -46
- hiplot/static/built/hiplot_test.js +0 -238
- hiplot/static/built/hiplot_test.licenses.txt +0 -682
- hiplot/static/built/hiplot_web.d.ts +0 -3
- hiplot/static/built/hiplot_web.js +0 -54
- hiplot/static/built/infertypes.d.ts +0 -38
- hiplot/static/built/infertypes.js +0 -316
- hiplot/static/built/plotxy.d.ts +0 -62
- hiplot/static/built/plotxy.js +0 -602
- hiplot/static/built/plugin.d.ts +0 -38
- hiplot/static/built/plugin.js +0 -8
- hiplot/static/built/rowsdisplaytable.d.ts +0 -35
- hiplot/static/built/rowsdisplaytable.js +0 -284
- hiplot/static/built/streamlit_component/hiplot.bundle.js +0 -3
- hiplot/static/built/types.d.ts +0 -64
- hiplot/static/built/types.js +0 -55
- hiplot_mm-0.0.2.dist-info/METADATA +0 -106
- hiplot_mm-0.0.2.dist-info/RECORD +0 -77
- {hiplot_mm-0.0.2.dist-info → hiplot_mm-0.0.3rc1.dist-info/licenses}/LICENSE +0 -0
- {hiplot_mm-0.0.2.dist-info → hiplot_mm-0.0.3rc1.dist-info/licenses}/NOTICE +0 -0
- {hiplot_mm-0.0.2.dist-info → hiplot_mm-0.0.3rc1.dist-info}/top_level.txt +0 -0
hiplot/__init__.py
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
from .experiment import (Experiment, ExperimentFetcherDoesntApply, ExperimentValidationError, ExperimentValidationCircularRef,
|
|
6
6
|
ExperimentValidationMissingParent, Datapoint, ExperimentDisplayed, ValueDef, ValueType, Displays)
|
|
7
7
|
from .server import run_server, run_server_main
|
|
8
|
-
from .pkginfo import
|
|
8
|
+
from .pkginfo import __version__, package_name
|
|
9
9
|
|
|
10
10
|
from . import fetchers
|
|
11
11
|
|
hiplot/fetchers.py
CHANGED
|
@@ -306,7 +306,7 @@ def get_fetcher(fetcher_spec: str) -> hip.ExperimentFetcher:
|
|
|
306
306
|
if module is None:
|
|
307
307
|
raise RuntimeError(f"Unable to create fetcher '{fetcher_spec}'")
|
|
308
308
|
|
|
309
|
-
return getattr(module, parts[-1])
|
|
309
|
+
return getattr(module, parts[-1])
|
|
310
310
|
|
|
311
311
|
|
|
312
312
|
def get_fetchers(add_fetchers: tp.List[str]) -> tp.List[hip.ExperimentFetcher]:
|
hiplot/fetchers_demo.py
CHANGED
|
@@ -50,8 +50,8 @@ def demo_line_xy() -> hip.Experiment:
|
|
|
50
50
|
if i > 10:
|
|
51
51
|
from_parent = random.choice(exp.datapoints[-10:])
|
|
52
52
|
dp.from_uid = from_parent.uid # <-- Connect the parent to the child
|
|
53
|
-
dp.values['loss'] += from_parent.values['loss']
|
|
54
|
-
dp.values['param'] *= from_parent.values['param']
|
|
53
|
+
dp.values['loss'] += from_parent.values['loss']
|
|
54
|
+
dp.values['param'] *= from_parent.values['param']
|
|
55
55
|
exp.datapoints.append(dp)
|
|
56
56
|
# DEMO_LINE_XY_END
|
|
57
57
|
return exp
|
hiplot/ipython.py
CHANGED
|
@@ -8,11 +8,38 @@ import typing as t
|
|
|
8
8
|
import json
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
|
|
11
|
-
import IPython.display
|
|
12
|
-
from ipykernel.comm import Comm
|
|
13
11
|
from . import experiment as exp
|
|
14
12
|
from .render import escapejs, make_experiment_standalone_page
|
|
15
13
|
|
|
14
|
+
# Lazy imports for optional dependencies
|
|
15
|
+
if t.TYPE_CHECKING:
|
|
16
|
+
import IPython.display
|
|
17
|
+
from ipykernel.comm import Comm
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _get_ipython_display() -> t.Any:
|
|
21
|
+
"""Lazy import of IPython.display with helpful error message."""
|
|
22
|
+
try:
|
|
23
|
+
import IPython.display
|
|
24
|
+
return IPython.display
|
|
25
|
+
except ImportError as e:
|
|
26
|
+
raise ImportError(
|
|
27
|
+
"IPython is required for notebook support. "
|
|
28
|
+
"Install it with: pip install hiplot-mm[notebook]"
|
|
29
|
+
) from e
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _get_comm_class() -> t.Any:
|
|
33
|
+
"""Lazy import of ipykernel.comm.Comm with helpful error message."""
|
|
34
|
+
try:
|
|
35
|
+
from ipykernel.comm import Comm
|
|
36
|
+
return Comm
|
|
37
|
+
except ImportError as e:
|
|
38
|
+
raise ImportError(
|
|
39
|
+
"ipykernel is required for notebook support. "
|
|
40
|
+
"Install it with: pip install hiplot-mm[notebook]"
|
|
41
|
+
) from e
|
|
42
|
+
|
|
16
43
|
|
|
17
44
|
class GetSelectedFailure(Exception):
|
|
18
45
|
pass
|
|
@@ -27,8 +54,9 @@ class NotebookJSBundleInjector:
|
|
|
27
54
|
|
|
28
55
|
@classmethod
|
|
29
56
|
def ensure_injected(cls) -> None:
|
|
57
|
+
IPython_display = _get_ipython_display()
|
|
30
58
|
bundle = Path(__file__).parent / "static" / "built" / "hiplot.bundle.js"
|
|
31
|
-
|
|
59
|
+
IPython_display.display(IPython_display.Javascript(f"""
|
|
32
60
|
{bundle.read_text("utf-8")}
|
|
33
61
|
// Local variables can't be accessed in other cells, so let's
|
|
34
62
|
// manually create a global variable
|
|
@@ -76,12 +104,14 @@ class IPythonExperimentDisplayed(exp.ExperimentDisplayed):
|
|
|
76
104
|
self._selected_ids: t.List[str] = []
|
|
77
105
|
self._last_data_per_type: t.Dict[str, t.Any] = {}
|
|
78
106
|
|
|
79
|
-
|
|
107
|
+
Comm = _get_comm_class()
|
|
108
|
+
|
|
109
|
+
def target_func(comm: "Comm", open_msg: t.Dict[str, t.Any]) -> None: # pylint: disable=unused-argument
|
|
80
110
|
# comm is the kernel Comm instance
|
|
81
111
|
# msg is the comm_open message
|
|
82
112
|
|
|
83
113
|
# Register handler for later messages
|
|
84
|
-
@comm.on_msg
|
|
114
|
+
@comm.on_msg
|
|
85
115
|
def _recv(msg: t.Dict[str, t.Any]) -> None:
|
|
86
116
|
self._num_recv += 1
|
|
87
117
|
msg_data = msg["content"]["data"]
|
|
@@ -89,7 +119,7 @@ class IPythonExperimentDisplayed(exp.ExperimentDisplayed):
|
|
|
89
119
|
self._last_data_per_type[msg_data["type"]] = msg_data["data"]
|
|
90
120
|
|
|
91
121
|
try:
|
|
92
|
-
ip: Any = get_ipython() # type: ignore # pylint: disable=undefined-variable
|
|
122
|
+
ip: t.Any = get_ipython() # type: ignore # pylint: disable=undefined-variable
|
|
93
123
|
ip.kernel.comm_manager.register_target(comm_name, target_func)
|
|
94
124
|
except NameError: # NameError: name 'get_ipython' is not defined
|
|
95
125
|
# We are not in an ipython environment - for example in testing
|
|
@@ -115,7 +145,7 @@ class IPythonExperimentDisplayed(exp.ExperimentDisplayed):
|
|
|
115
145
|
last_msg = self._last_data_per_type.get("brush_extents")
|
|
116
146
|
if last_msg is None:
|
|
117
147
|
raise self.no_data_received_error
|
|
118
|
-
return last_msg
|
|
148
|
+
return last_msg
|
|
119
149
|
|
|
120
150
|
|
|
121
151
|
def _should_embed_js_with_html() -> bool:
|
|
@@ -133,6 +163,8 @@ def display_exp(
|
|
|
133
163
|
embed_js_with_html: t.Optional[bool] = None,
|
|
134
164
|
**kwargs: t.Any
|
|
135
165
|
) -> IPythonExperimentDisplayed:
|
|
166
|
+
IPython_display = _get_ipython_display()
|
|
167
|
+
|
|
136
168
|
if embed_js_with_html is None:
|
|
137
169
|
embed_js_with_html = _should_embed_js_with_html()
|
|
138
170
|
|
|
@@ -185,5 +217,5 @@ catch(err) {{
|
|
|
185
217
|
else:
|
|
186
218
|
NotebookJSBundleInjector.ensure_injected()
|
|
187
219
|
|
|
188
|
-
|
|
220
|
+
IPython_display.display(IPython_display.HTML(index_html))
|
|
189
221
|
return displayed_xp
|
hiplot/pkginfo.py
CHANGED
|
@@ -2,5 +2,14 @@
|
|
|
2
2
|
# This source code is licensed under the MIT license found in the
|
|
3
3
|
# LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
6
|
+
|
|
7
|
+
package_name = "hiplot-mm"
|
|
8
|
+
|
|
9
|
+
# Dynamic version from installed package metadata
|
|
10
|
+
# This ensures __version__ matches pyproject.toml when installed via pip
|
|
11
|
+
try:
|
|
12
|
+
__version__ = version(package_name)
|
|
13
|
+
except PackageNotFoundError:
|
|
14
|
+
# Package is not installed (e.g., running from source checkout)
|
|
15
|
+
__version__ = "0.0.0.dev0"
|
hiplot/render.py
CHANGED
|
@@ -36,7 +36,7 @@ def html_inlinize(html: str, replace_local: bool = True) -> str:
|
|
|
36
36
|
static_root = str(Path(__file__).parent)
|
|
37
37
|
soup = BeautifulSoup(html, "html.parser")
|
|
38
38
|
for i in soup.find_all("link"):
|
|
39
|
-
href = i["href"]
|
|
39
|
+
href = str(i["href"])
|
|
40
40
|
if href.startswith("http") or href.startswith("//"):
|
|
41
41
|
continue
|
|
42
42
|
if not replace_local:
|
|
@@ -54,7 +54,7 @@ def html_inlinize(html: str, replace_local: bool = True) -> str:
|
|
|
54
54
|
i["href"] = f"data:{SUFFIX_TO_TYPE[file.suffix]};base64,{base64.b64encode(file.open('rb').read()).decode('ascii')}"
|
|
55
55
|
for i in soup.find_all("script"):
|
|
56
56
|
try:
|
|
57
|
-
src = i["src"]
|
|
57
|
+
src = str(i["src"])
|
|
58
58
|
except KeyError:
|
|
59
59
|
continue
|
|
60
60
|
if src.startswith("http") or src.startswith("//"):
|
hiplot/server.py
CHANGED
|
@@ -18,8 +18,14 @@ def run_server(fetchers: List[exp.ExperimentFetcher], host: str = '127.0.0.1', p
|
|
|
18
18
|
"""
|
|
19
19
|
Runs the HiPlot server, given a list of ExperimentFetchers - functions that convert a URI into a :class:`hiplot.Experiment`
|
|
20
20
|
"""
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
try:
|
|
22
|
+
from flask import Flask, render_template, jsonify, request
|
|
23
|
+
from flask_compress import Compress
|
|
24
|
+
except ImportError as e:
|
|
25
|
+
raise ImportError(
|
|
26
|
+
"Flask is required to run the HiPlot server. "
|
|
27
|
+
"Install it with: pip install hiplot-mm[server]"
|
|
28
|
+
) from e
|
|
23
29
|
|
|
24
30
|
app = Flask(__name__)
|
|
25
31
|
|
|
@@ -45,7 +51,7 @@ def run_server(fetchers: List[exp.ExperimentFetcher], host: str = '127.0.0.1', p
|
|
|
45
51
|
|
|
46
52
|
def run_server_main() -> int:
|
|
47
53
|
parser = argparse.ArgumentParser(prog="HiPlot", description="Start HiPlot webserver")
|
|
48
|
-
parser.add_argument('--version', action='version', version=f'{pkginfo.package_name} {pkginfo.
|
|
54
|
+
parser.add_argument('--version', action='version', version=f'{pkginfo.package_name} {pkginfo.__version__}')
|
|
49
55
|
parser.add_argument("--host", type=str, default="127.0.0.1")
|
|
50
56
|
parser.add_argument("--port", type=int, default=5005)
|
|
51
57
|
parser.add_argument("--dev", action='store_true', help="Enable Flask Debug mode (watches for files modifications, etc..)")
|