landscape-widget 0.2.0 → 0.3.0-alpha
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.
- package/README.md +218 -0
- package/css/widget.css +8 -0
- package/dist/index.js +1 -1
- package/lib/Analysis.types.js +26 -0
- package/lib/Analysis.utils.js +5 -0
- package/lib/ForceAtlasAnimator.js +147 -0
- package/lib/GraphContainer.js +105 -0
- package/lib/GraphLayout.js +440 -0
- package/lib/GraphLayout.types.js +6 -0
- package/lib/InitialLayoutWorker.js +31 -0
- package/lib/IterateNoIntercomponentRepel.js +282 -0
- package/lib/LoadGraph.js +132 -0
- package/lib/SigmaLasso.js +118 -0
- package/lib/enum/layout.js +24 -0
- package/lib/explicitComponentLayout.js +155 -0
- package/lib/extension.js +18 -0
- package/lib/icons/AnalysisIcon.js +4 -0
- package/lib/icons/ChevronSolid.js +4 -0
- package/lib/icons/ClearSelection.js +5 -0
- package/lib/icons/FullScreenEnter.js +8 -0
- package/lib/icons/FullScreenExit.js +8 -0
- package/lib/icons/Gradient.js +6 -0
- package/lib/icons/Grid.js +4 -0
- package/lib/icons/Invert.js +5 -0
- package/lib/icons/Lasso.js +5 -0
- package/lib/icons/List.js +9 -0
- package/lib/icons/Minus.js +4 -0
- package/lib/icons/Plus.js +5 -0
- package/lib/icons/Reset.js +5 -0
- package/lib/icons/index.js +13 -0
- package/lib/index.js +3 -0
- package/lib/landscape.js +226 -0
- package/lib/mui/Tooltip.js +30 -0
- package/lib/plugin.js +27 -0
- package/lib/public-path.js +4 -0
- package/lib/version.js +16 -0
- package/package.json +107 -1
- package/NOTICE.txt +0 -274
package/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# jupyter-landscape
|
|
2
|
+
|
|
3
|
+
Jupyter widget for interactive graph visualization. Supports live updates to
|
|
4
|
+
colors and reports selected nodes back to the Python object.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
If you do not need to modify this package, the simplest way to get started is to
|
|
9
|
+
download `environment.yml` and the built wheel from [the latest
|
|
10
|
+
release](https://github.com/BlueLightAI/jupyter-landscapes/releases/latest).
|
|
11
|
+
Then run the following:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
conda env create -f environment.yml
|
|
15
|
+
conda activate landscape-widget
|
|
16
|
+
pip install landscape_widget-VERSION-py3-none-any.whl
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If you are using this outside of conda, you will need to create a virtual
|
|
20
|
+
environment manually and install the `mapper-core` dependency first:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
# create and activate your virtual environment
|
|
24
|
+
pip install git+https://github.com/BlueLightAI/mapper-core.git
|
|
25
|
+
pip install landscape_widget-VERSION-py3-none-any.whl
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This also applies if you want to use the package in a different conda
|
|
29
|
+
environment than the one constructed from the `environment.yml` file. One of
|
|
30
|
+
the package's dependencies is `mapper-core`, which `pip` does not know how to
|
|
31
|
+
resolve, so you need to install it manually.
|
|
32
|
+
|
|
33
|
+
The widget is known to work in classic (version < 7) Jupyter notebooks, Jupyter
|
|
34
|
+
Lab, and Visual Studio Code notebooks. Because it works in Jupyter Lab, it
|
|
35
|
+
should work in notebook v7 as well, but this has not been tested. In order for a
|
|
36
|
+
new or updated installation to be usable in VSCode, you will need to close and
|
|
37
|
+
reopen the editor window hosting the notebooks.
|
|
38
|
+
|
|
39
|
+
You may run into strange and unreliable widget behavior in some installations. A
|
|
40
|
+
major source of these issues appears to be [this Jupyter
|
|
41
|
+
bug](https://github.com/jupyter/notebook/issues/6721). The latest versions of
|
|
42
|
+
the Jupyter dependencies do not seem to suffer from these problems.
|
|
43
|
+
|
|
44
|
+
## Development Installation
|
|
45
|
+
|
|
46
|
+
Clone the repository. Because this project uses a git submodule, you will need
|
|
47
|
+
to do the following:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
git clone --recurse-submodules https://github.com/BlueLightAI/jupyter-landscapes
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Then create a new environment:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
conda env create -f environment-dev.yml
|
|
57
|
+
conda activate landscape-widget-dev
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If you are using a non-conda environment, you will need an available
|
|
61
|
+
installation of node, npm, and the yarn package manager, as well as (again),
|
|
62
|
+
mapper-core.
|
|
63
|
+
|
|
64
|
+
You will then need to build the `blai-graph-widget` package:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
cd blai-graph-widget
|
|
68
|
+
yarn install
|
|
69
|
+
yarn build
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If you update the files in this submodule (e.g. by changing to a different
|
|
73
|
+
branch, or pulling new updates) you will need to repeat this step before
|
|
74
|
+
building the main package again.
|
|
75
|
+
|
|
76
|
+
Back in the root project directory, install the python package. This will also
|
|
77
|
+
build the TypeScript code.
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
pip install -e ".[dev]"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This builds and installs both the Python and JavaScript portions of the widget.
|
|
84
|
+
The Python code is installed in editable mode and will be automatically updated
|
|
85
|
+
without the need to reinstall. However, if you change the TypeScript code, it
|
|
86
|
+
will not update the extension by default (even if you run `yarn build`).
|
|
87
|
+
Rerunning `pip install -e .` whenever you make a change to the frontend code is a
|
|
88
|
+
safe way to work around this.
|
|
89
|
+
|
|
90
|
+
Before committing any changes to the repo, install the pre-commit hooks and
|
|
91
|
+
verify they run:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
pre-commit install
|
|
95
|
+
pre-commit run --all
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
If you want the JavaScript portion of the extension to automatically update when
|
|
99
|
+
you rebuild, you will need to manually install the extension in an editable
|
|
100
|
+
mode. Unfortunately, this interferes with the `pip install` process, so beware.
|
|
101
|
+
To install the extension in editable mode for the classic notebook, run
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
jupyter nbextension install --sys-prefix --symlink --overwrite --py landscape_widget
|
|
105
|
+
jupyter nbextension enable --sys-prefix --py landscape_widget
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
This replaces the `$SYS_PREFIX/share/jupyter/nbextensions/landscape_widget`
|
|
109
|
+
directory with a symlink to the corresponding `landscape_widget/nbextension`
|
|
110
|
+
directory in your source tree; this directory is repopulated whenever you run
|
|
111
|
+
`yarn build`. (Note that because this relies on symlinks, it doesn't work on
|
|
112
|
+
Windows, but I don't think anyone will be using that in the near future anyway.)
|
|
113
|
+
Unfortunately, if you run `pip install` after doing this, it will run into a
|
|
114
|
+
problem, because it first tries to remove the contents of that directory (which
|
|
115
|
+
removes them from your source tree as well) and then tries to use your source
|
|
116
|
+
tree to repopulate them. (In particular, this happens because there is a
|
|
117
|
+
required file in this directory that is not built by the build process, and it
|
|
118
|
+
gets deleted by pip but is never regenerated.) So to work around this, you will
|
|
119
|
+
need to uninstall the extension before rerunning `pip install`:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
jupyter nbextension uninstall --sys-prefix --py landscape_widget
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
These instructions currently seem to work for running the notebook in VSCode as well.
|
|
126
|
+
|
|
127
|
+
Things should be a bit simpler for Jupyter Lab installation. The Python package
|
|
128
|
+
must first be installed in editable mode. Then run
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
jupyter labextension develop --overwrite .
|
|
132
|
+
yarn run build
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
This symlinks `landscape_widget/labextension` to the folder where Jupyter Lab
|
|
136
|
+
expects the extension and rebuilds the extension.
|
|
137
|
+
|
|
138
|
+
### How to see your changes
|
|
139
|
+
|
|
140
|
+
Even when the package is installed in develop mode, you will need to restart the
|
|
141
|
+
Jupyter kernel to see the effects of changes you have made to the Python code.
|
|
142
|
+
(Using the magic `%load_ext autoreload` might work here, though.) Changes to the
|
|
143
|
+
JavaScript code should appear after simply reloading the notebook page (although
|
|
144
|
+
restarting the kernel doesn't hurt there either). In VSCode, you will need to
|
|
145
|
+
close and reopen the editor window (not just the tab) in order to reload the JS
|
|
146
|
+
code.
|
|
147
|
+
|
|
148
|
+
If you use JupyterLab to develop then you can watch the source directory and run
|
|
149
|
+
JupyterLab at the same time in different terminals to watch for changes in the
|
|
150
|
+
extension's source and automatically rebuild the widget.
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
# Watch the source directory in one terminal, automatically rebuilding when needed
|
|
154
|
+
yarn run watch
|
|
155
|
+
# Run JupyterLab in another terminal
|
|
156
|
+
jupyter lab
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This should also work with `jupyter notebook` as long as the extension has been
|
|
160
|
+
symlinked.
|
|
161
|
+
|
|
162
|
+
After a change wait for the build to finish and then refresh your browser and
|
|
163
|
+
the changes should take effect. You may prefer to manually run `yarn build`
|
|
164
|
+
after making changes to the Typescript code, as the compilation process can be
|
|
165
|
+
computationally intensive.
|
|
166
|
+
|
|
167
|
+
### Using a dev version in another project
|
|
168
|
+
|
|
169
|
+
To use an in-development version in another project (Cobalt, for instance), the
|
|
170
|
+
process is similar. Find the file system path to the development directory for
|
|
171
|
+
jupyter-landscapes, which we'll call `$WIDGET_PATH`. Then, from the development
|
|
172
|
+
directory (and inside the correct Python virtual environment) for the other
|
|
173
|
+
project, run the following:
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
pip install -e $WIDGET_PATH
|
|
177
|
+
|
|
178
|
+
jupyter nbextension install --sys-prefix --symlink --overwrite --py landscape_widget
|
|
179
|
+
jupyter nbextension enable --sys-prefix --py landscape_widget
|
|
180
|
+
|
|
181
|
+
jupyter labextension develop --overwrite $WIDGET_PATH
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Updates to the JavaScript portion of the widget will then be available in the
|
|
185
|
+
other project as soon as they have been built.
|
|
186
|
+
|
|
187
|
+
If for whatever reason you need to rerun the `pip install` step, run
|
|
188
|
+
|
|
189
|
+
```sh
|
|
190
|
+
jupyter nbextension uninstall --sys-prefix --py landscape_widget
|
|
191
|
+
```
|
|
192
|
+
first.
|
|
193
|
+
|
|
194
|
+
### Updating the version
|
|
195
|
+
|
|
196
|
+
To update the version, install tbump and use it to bump the version.
|
|
197
|
+
By default it will also create a tag.
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
pip install tbump
|
|
201
|
+
tbump <new-version>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### License Report
|
|
205
|
+
### `yarn build:license-report-json`
|
|
206
|
+
### `yarn build:license-report-html`
|
|
207
|
+
You can use the following commands to generate license reports in JSON and HTML formats.
|
|
208
|
+
|
|
209
|
+
- `yarn build:license-report-json` will generate a `license-report.json` file in the root of the project, containing the license information for all project dependencies.
|
|
210
|
+
- `yarn build:license-report-html` will generate a `license-report.html` file in the root of the project, containing the license information for all project dependencies.
|
|
211
|
+
|
|
212
|
+
#### Adding Production-Only Option
|
|
213
|
+
To generate a license report that includes only production packages, you can run the following commands with the `--only=prod` parameter:
|
|
214
|
+
|
|
215
|
+
- `yarn build:license-report-json --only=prod` to generate a JSON report for production dependencies only.
|
|
216
|
+
- `yarn build:license-report-html --only=prod` to generate an HTML report for production dependencies only.
|
|
217
|
+
|
|
218
|
+
For more details, refer to the [license-report](https://www.npmjs.com/package/license-report) documentation.
|