hiplot-mm 0.0.2__tar.gz → 0.0.3rc1__tar.gz

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.
Files changed (48) hide show
  1. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/MANIFEST.in +1 -0
  2. hiplot_mm-0.0.3rc1/PKG-INFO +174 -0
  3. hiplot_mm-0.0.3rc1/README.md +116 -0
  4. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/__init__.py +1 -1
  5. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/fetchers.py +1 -1
  6. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/fetchers_demo.py +2 -2
  7. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/ipython.py +40 -8
  8. hiplot_mm-0.0.3rc1/hiplot/pkginfo.py +15 -0
  9. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/render.py +2 -2
  10. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/server.py +9 -3
  11. hiplot_mm-0.0.3rc1/hiplot/static/built/hiplot.bundle.js +3 -0
  12. hiplot_mm-0.0.3rc1/hiplot/static/built/streamlit_component/hiplot_streamlit.bundle.js +3 -0
  13. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/streamlit_helpers.py +11 -2
  14. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/test_render.py +2 -2
  15. hiplot_mm-0.0.3rc1/hiplot_mm.egg-info/PKG-INFO +174 -0
  16. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot_mm.egg-info/SOURCES.txt +1 -1
  17. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot_mm.egg-info/entry_points.txt +1 -2
  18. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot_mm.egg-info/requires.txt +20 -6
  19. hiplot_mm-0.0.3rc1/pyproject.toml +108 -0
  20. hiplot-mm-0.0.2/PKG-INFO +0 -87
  21. hiplot-mm-0.0.2/README.md +0 -71
  22. hiplot-mm-0.0.2/hiplot/pkginfo.py +0 -6
  23. hiplot-mm-0.0.2/hiplot/static/built/hiplot.bundle.js +0 -3
  24. hiplot-mm-0.0.2/hiplot/static/built/streamlit_component/hiplot_streamlit.bundle.js +0 -3
  25. hiplot-mm-0.0.2/hiplot_mm.egg-info/PKG-INFO +0 -87
  26. hiplot-mm-0.0.2/setup.py +0 -58
  27. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/LICENSE +0 -0
  28. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/NOTICE +0 -0
  29. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/__main__.py +0 -0
  30. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/compress.py +0 -0
  31. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/experiment.py +0 -0
  32. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/py.typed +0 -0
  33. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/static/built/streamlit_component/index.html +0 -0
  34. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/static/icon-w.svg +0 -0
  35. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/static/icon.png +0 -0
  36. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/static/icon.svg +0 -0
  37. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/static/logo-w.svg +0 -0
  38. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/static/logo.png +0 -0
  39. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/static/logo.svg +0 -0
  40. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/static/thumbnail.png +0 -0
  41. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/templates/index.html +0 -0
  42. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/test_experiment.py +0 -0
  43. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot/test_fetchers.py +0 -0
  44. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot_mm.egg-info/dependency_links.txt +0 -0
  45. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/hiplot_mm.egg-info/top_level.txt +0 -0
  46. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/requirements/dev.txt +0 -0
  47. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/requirements/main.txt +0 -0
  48. {hiplot-mm-0.0.2 → hiplot_mm-0.0.3rc1}/setup.cfg +0 -0
@@ -1,4 +1,5 @@
1
1
  include LICENSE README.md
2
+ include pyproject.toml
2
3
  include requirements/*.txt
3
4
  include hiplot/static/*
4
5
  include hiplot/static/built/*
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: hiplot-mm
3
+ Version: 0.0.3rc1
4
+ Summary: High dimensional Interactive Plotting tool
5
+ Author: Facebook AI Research, mathematicalmichael @ Mind the Math, LLC
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/mindthemath/hiplot
8
+ Project-URL: Documentation, https://facebookresearch.github.io/hiplot/
9
+ Project-URL: Repository, https://github.com/mindthemath/hiplot
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Scientific/Engineering :: Visualization
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ License-File: NOTICE
27
+ Requires-Dist: beautifulsoup4
28
+ Requires-Dist: jinja2
29
+ Provides-Extra: server
30
+ Requires-Dist: flask; extra == "server"
31
+ Requires-Dist: flask-compress; extra == "server"
32
+ Provides-Extra: notebook
33
+ Requires-Dist: ipython>=7.0.1; extra == "notebook"
34
+ Requires-Dist: ipykernel; extra == "notebook"
35
+ Provides-Extra: streamlit
36
+ Requires-Dist: streamlit>=0.63; extra == "streamlit"
37
+ Provides-Extra: all
38
+ Requires-Dist: hiplot-mm[notebook,server,streamlit]; extra == "all"
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest; extra == "dev"
41
+ Requires-Dist: ty; extra == "dev"
42
+ Requires-Dist: ipykernel; extra == "dev"
43
+ Requires-Dist: wheel; extra == "dev"
44
+ Requires-Dist: mistune==0.8.4; extra == "dev"
45
+ Requires-Dist: twine; extra == "dev"
46
+ Requires-Dist: pre-commit; extra == "dev"
47
+ Requires-Dist: pandas; extra == "dev"
48
+ Requires-Dist: streamlit>=0.63; extra == "dev"
49
+ Requires-Dist: beautifulsoup4; extra == "dev"
50
+ Requires-Dist: optuna; extra == "dev"
51
+ Requires-Dist: sphinx==5.2.0; extra == "dev"
52
+ Requires-Dist: guzzle_sphinx_theme==0.7.11; extra == "dev"
53
+ Requires-Dist: m2r2>=0.3.4; extra == "dev"
54
+ Requires-Dist: flask; extra == "dev"
55
+ Requires-Dist: flask-compress; extra == "dev"
56
+ Requires-Dist: ipython>=7.0.1; extra == "dev"
57
+ Dynamic: license-file
58
+
59
+ # HiPlot - High dimensional Interactive Plotting
60
+
61
+ ![Logo](https://raw.githubusercontent.com/mindthemath/hiplot/main/hiplot/static/logo.png)
62
+
63
+ [![CI](https://github.com/mindthemath/hiplot/actions/workflows/ci.yml/badge.svg)](https://github.com/mindthemath/hiplot/actions/workflows/ci.yml)
64
+ [![Release](https://github.com/mindthemath/hiplot/actions/workflows/release.yml/badge.svg)](https://github.com/mindthemath/hiplot/actions/workflows/release.yml)
65
+ [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
66
+ [![PyPI version](https://img.shields.io/pypi/v/hiplot-mm.svg)](https://pypi.python.org/pypi/hiplot-mm/)
67
+ [![PyPI downloads](https://img.shields.io/pypi/dm/hiplot-mm.svg)](https://pypi.python.org/pypi/hiplot-mm/)
68
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mindthemath/hiplot/blob/main/examples/HiPlotColabExample.ipynb)
69
+
70
+ > **Community-maintained fork**: This is a community-maintained fork of [Facebook Research's HiPlot](https://github.com/facebookresearch/hiplot), which has been archived. We aim to keep the project alive with bug fixes, security updates, and new features.
71
+
72
+ HiPlot is a lightweight interactive visualization tool to help AI researchers discover correlations and patterns in high-dimensional data using parallel plots and other graphical ways to represent information.
73
+
74
+ ### [Try a demo now with sweep data](https://mindthemath.github.io/hiplot/_static/demo/ml1.csv.html) or [upload your CSV](https://mindthemath.github.io/hiplot/_static/hiplot_upload.html) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mindthemath/hiplot/blob/main/examples/HiPlotColabExample.ipynb)
75
+
76
+ There are several modes to HiPlot:
77
+ - As a web-server (if your data is a CSV for instance)
78
+ - In a jupyter notebook (to visualize python data), or in [Streamlit apps](https://mindthemath.github.io/hiplot/tuto_streamlit.html)
79
+ - In CLI to render standalone HTML
80
+
81
+
82
+ ```bash
83
+ # Core package (HTML export only)
84
+ pip install hiplot-mm
85
+
86
+ # With Jupyter notebook support
87
+ pip install hiplot-mm[notebook]
88
+
89
+ # With web server support (hiplot CLI command)
90
+ pip install hiplot-mm[server]
91
+
92
+ # With Streamlit support
93
+ pip install hiplot-mm[streamlit]
94
+
95
+ # Everything
96
+ pip install hiplot-mm[all]
97
+ ```
98
+
99
+ If you have a Jupyter notebook, you can get started with something as simple as:
100
+
101
+ ```python
102
+ import hiplot as hip
103
+ data = [{'dropout':0.1, 'lr': 0.001, 'loss': 10.0, 'optimizer': 'SGD'},
104
+ {'dropout':0.15, 'lr': 0.01, 'loss': 3.5, 'optimizer': 'Adam'},
105
+ {'dropout':0.3, 'lr': 0.1, 'loss': 4.5, 'optimizer': 'Adam'}]
106
+ hip.Experiment.from_iterable(data).display()
107
+ ```
108
+
109
+ ### [See the live result](https://mindthemath.github.io/hiplot/_static/demo/demo_basic_usage.html)
110
+ ![Result](https://raw.githubusercontent.com/mindthemath/hiplot/main/assets/notebook.png)
111
+
112
+ ## Links
113
+
114
+ * Repository: https://github.com/mindthemath/hiplot
115
+ * Documentation: https://mindthemath.github.io/hiplot/
116
+ * PyPI package: https://pypi.org/project/hiplot-mm/
117
+ * Examples: https://github.com/mindthemath/hiplot/tree/main/examples
118
+ * Original blog post: https://ai.facebook.com/blog/hiplot-high-dimensional-interactive-plots-made-easy/
119
+
120
+
121
+ ## Development
122
+
123
+ To build from source:
124
+
125
+ ```bash
126
+ # Install dependencies
127
+ bun install
128
+ uv sync --all-extras
129
+
130
+ # Build JavaScript bundles
131
+ bun run build
132
+
133
+ # Build Python package
134
+ uv build
135
+
136
+ # Or use the all-in-one build script
137
+ ./build.sh
138
+ ```
139
+
140
+ **Output directories:**
141
+ - `npm-dist/` - NPM package artifacts
142
+ - `dist/` - Python wheel and sdist
143
+ - `hiplot/static/built/` - JS bundle included in Python package
144
+
145
+ **Run the dev server:**
146
+ ```bash
147
+ uv run hiplot --port 8765
148
+ ```
149
+
150
+
151
+ ## Citing
152
+
153
+ ```bibtex
154
+ @misc{hiplot,
155
+ author = {Haziza, D. and Rapin, J. and Synnaeve, G.},
156
+ title = {{Hiplot, interactive high-dimensionality plots}},
157
+ year = {2020},
158
+ publisher = {GitHub},
159
+ journal = {GitHub repository},
160
+ howpublished = {\url{https://github.com/facebookresearch/hiplot}},
161
+ }
162
+ ```
163
+
164
+ ## Credits
165
+ Inspired by and based on code from [Kai Chang](http://bl.ocks.org/syntagmatic/3150059), [Mike Bostock](http://bl.ocks.org/1341021) and [Jason Davies](http://bl.ocks.org/1341281).
166
+
167
+ External contributors (*please add your name when you submit your first pull request*):
168
+ - [louismartin](https://github.com/louismartin)
169
+ - [GoldenCorgi](https://github.com/GoldenCorgi)
170
+ - [callistachang](https://github.com/callistachang)
171
+
172
+
173
+ ## License
174
+ HiPlot is [MIT](LICENSE) licensed, as found in the [LICENSE](LICENSE) file.
@@ -0,0 +1,116 @@
1
+ # HiPlot - High dimensional Interactive Plotting
2
+
3
+ ![Logo](https://raw.githubusercontent.com/mindthemath/hiplot/main/hiplot/static/logo.png)
4
+
5
+ [![CI](https://github.com/mindthemath/hiplot/actions/workflows/ci.yml/badge.svg)](https://github.com/mindthemath/hiplot/actions/workflows/ci.yml)
6
+ [![Release](https://github.com/mindthemath/hiplot/actions/workflows/release.yml/badge.svg)](https://github.com/mindthemath/hiplot/actions/workflows/release.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
8
+ [![PyPI version](https://img.shields.io/pypi/v/hiplot-mm.svg)](https://pypi.python.org/pypi/hiplot-mm/)
9
+ [![PyPI downloads](https://img.shields.io/pypi/dm/hiplot-mm.svg)](https://pypi.python.org/pypi/hiplot-mm/)
10
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mindthemath/hiplot/blob/main/examples/HiPlotColabExample.ipynb)
11
+
12
+ > **Community-maintained fork**: This is a community-maintained fork of [Facebook Research's HiPlot](https://github.com/facebookresearch/hiplot), which has been archived. We aim to keep the project alive with bug fixes, security updates, and new features.
13
+
14
+ HiPlot is a lightweight interactive visualization tool to help AI researchers discover correlations and patterns in high-dimensional data using parallel plots and other graphical ways to represent information.
15
+
16
+ ### [Try a demo now with sweep data](https://mindthemath.github.io/hiplot/_static/demo/ml1.csv.html) or [upload your CSV](https://mindthemath.github.io/hiplot/_static/hiplot_upload.html) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mindthemath/hiplot/blob/main/examples/HiPlotColabExample.ipynb)
17
+
18
+ There are several modes to HiPlot:
19
+ - As a web-server (if your data is a CSV for instance)
20
+ - In a jupyter notebook (to visualize python data), or in [Streamlit apps](https://mindthemath.github.io/hiplot/tuto_streamlit.html)
21
+ - In CLI to render standalone HTML
22
+
23
+
24
+ ```bash
25
+ # Core package (HTML export only)
26
+ pip install hiplot-mm
27
+
28
+ # With Jupyter notebook support
29
+ pip install hiplot-mm[notebook]
30
+
31
+ # With web server support (hiplot CLI command)
32
+ pip install hiplot-mm[server]
33
+
34
+ # With Streamlit support
35
+ pip install hiplot-mm[streamlit]
36
+
37
+ # Everything
38
+ pip install hiplot-mm[all]
39
+ ```
40
+
41
+ If you have a Jupyter notebook, you can get started with something as simple as:
42
+
43
+ ```python
44
+ import hiplot as hip
45
+ data = [{'dropout':0.1, 'lr': 0.001, 'loss': 10.0, 'optimizer': 'SGD'},
46
+ {'dropout':0.15, 'lr': 0.01, 'loss': 3.5, 'optimizer': 'Adam'},
47
+ {'dropout':0.3, 'lr': 0.1, 'loss': 4.5, 'optimizer': 'Adam'}]
48
+ hip.Experiment.from_iterable(data).display()
49
+ ```
50
+
51
+ ### [See the live result](https://mindthemath.github.io/hiplot/_static/demo/demo_basic_usage.html)
52
+ ![Result](https://raw.githubusercontent.com/mindthemath/hiplot/main/assets/notebook.png)
53
+
54
+ ## Links
55
+
56
+ * Repository: https://github.com/mindthemath/hiplot
57
+ * Documentation: https://mindthemath.github.io/hiplot/
58
+ * PyPI package: https://pypi.org/project/hiplot-mm/
59
+ * Examples: https://github.com/mindthemath/hiplot/tree/main/examples
60
+ * Original blog post: https://ai.facebook.com/blog/hiplot-high-dimensional-interactive-plots-made-easy/
61
+
62
+
63
+ ## Development
64
+
65
+ To build from source:
66
+
67
+ ```bash
68
+ # Install dependencies
69
+ bun install
70
+ uv sync --all-extras
71
+
72
+ # Build JavaScript bundles
73
+ bun run build
74
+
75
+ # Build Python package
76
+ uv build
77
+
78
+ # Or use the all-in-one build script
79
+ ./build.sh
80
+ ```
81
+
82
+ **Output directories:**
83
+ - `npm-dist/` - NPM package artifacts
84
+ - `dist/` - Python wheel and sdist
85
+ - `hiplot/static/built/` - JS bundle included in Python package
86
+
87
+ **Run the dev server:**
88
+ ```bash
89
+ uv run hiplot --port 8765
90
+ ```
91
+
92
+
93
+ ## Citing
94
+
95
+ ```bibtex
96
+ @misc{hiplot,
97
+ author = {Haziza, D. and Rapin, J. and Synnaeve, G.},
98
+ title = {{Hiplot, interactive high-dimensionality plots}},
99
+ year = {2020},
100
+ publisher = {GitHub},
101
+ journal = {GitHub repository},
102
+ howpublished = {\url{https://github.com/facebookresearch/hiplot}},
103
+ }
104
+ ```
105
+
106
+ ## Credits
107
+ Inspired by and based on code from [Kai Chang](http://bl.ocks.org/syntagmatic/3150059), [Mike Bostock](http://bl.ocks.org/1341021) and [Jason Davies](http://bl.ocks.org/1341281).
108
+
109
+ External contributors (*please add your name when you submit your first pull request*):
110
+ - [louismartin](https://github.com/louismartin)
111
+ - [GoldenCorgi](https://github.com/GoldenCorgi)
112
+ - [callistachang](https://github.com/callistachang)
113
+
114
+
115
+ ## License
116
+ HiPlot is [MIT](LICENSE) licensed, as found in the [LICENSE](LICENSE) file.
@@ -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 version as __version__, package_name
8
+ from .pkginfo import __version__, package_name
9
9
 
10
10
  from . import fetchers
11
11
 
@@ -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]) # type: ignore
309
+ return getattr(module, parts[-1])
310
310
 
311
311
 
312
312
  def get_fetchers(add_fetchers: tp.List[str]) -> tp.List[hip.ExperimentFetcher]:
@@ -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'] # type: ignore
54
- dp.values['param'] *= from_parent.values['param'] # type: ignore
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
@@ -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
- IPython.display.display(IPython.display.Javascript(f"""
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
- def target_func(comm: Comm, open_msg: t.Dict[str, t.Any]) -> None: # pylint: disable=unused-argument
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 # type: ignore
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 # type: ignore
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
- IPython.display.display(IPython.display.HTML(index_html))
220
+ IPython_display.display(IPython_display.HTML(index_html))
189
221
  return displayed_xp
@@ -0,0 +1,15 @@
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ # This source code is licensed under the MIT license found in the
3
+ # LICENSE file in the root directory of this source tree.
4
+
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"
@@ -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("//"):
@@ -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
- from flask import Flask, render_template, jsonify, request
22
- from flask_compress import Compress
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.version}')
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..)")