From 31038f83c0a107939efe7d7d747fd1e74fedd33f Mon Sep 17 00:00:00 2001 From: Joe Numainville Date: Thu, 25 Jul 2024 14:38:09 -0500 Subject: [PATCH 1/3] wip --- README.md | 42 ++++++++++++++++++++++++++++--- deephaven_ipywidgets/deephaven.py | 2 +- setup.py | 10 +++++++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e42e74a..5e165d9 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,17 @@ Deephaven Community IPython Widget Library ## Installation -You can install using `pip`: +You can install using `pip`. +If running with the embedded server, install with the following: +```shell +pip install "deephaven-ipywidgets[server]" +``` +This installs the embedded server. + +If connecting to a server running elsewhere, install with the following: ```bash -pip install deephaven-ipywidgets +pip install "deephaven-ipywidgets[client]" ``` If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable @@ -21,7 +28,7 @@ jupyter nbextension enable --py [--sys-prefix|--user|--system] deephaven-ipywidg ### Starting the server -First you'll need to start the [Deephaven server](https://github.com/deephaven/deephaven-core/blob/d73ef01cdf6fda43f7d03110995add26d16d4eae/py/embedded-server/README.md). +First, if you are using the embedded server, you'll need to start the [Deephaven server](https://github.com/deephaven/deephaven-core/blob/d73ef01cdf6fda43f7d03110995add26d16d4eae/py/embedded-server/README.md). ```python # Start up the Deephaven Server on port 8080 with token `iris` @@ -49,6 +56,35 @@ You can also pass in the size you would like the widget to be: display(DeephavenWidget(t, width=100, height=250)) ``` +### Connecting to a Remote Server + +If you are using the client to connect to an already running server, create a `pydeephaven` session. +See the [pydeephaven documentation](https://deephaven.io/core/docs/tutorials/pyclient-quickstart/) for more information. +```python +from pydeephaven import Session + +client_session = Session( + host="deephaven.local", + port=10000, + auth_type="io.deephaven.authentication.psk.PskAuthenticationHandler", + auth_token="YOUR_PASSWORD_HERE", +) +``` + +### Displaying Tables from a Remote Server + +The session can be used to create objects such as tables on the server and then display them in the widget. +```python +t = client_session.time_table("PT1s") +from deephaven_ipywidgets import DeephavenWidget +display(DeephavenWidget(t)) +``` + +You can also reference objects already created on the server. This code assumes a table named `t` exists on the server. +```python +display(DeephavenWidget("t", session=client_session)) +``` + ### Alternate Deephaven Server URL By default, the Deephaven server is located at `http://localhost:{port}`, where `{port}` is the port set in the Deephaven server creation call. If the server is not there, such as when running a Jupyter notebook in a Docker container, modify the `DEEPHAVEN_IPY_URL` environmental variable to the correct URL before creating a `DeephavenWidget`. diff --git a/deephaven_ipywidgets/deephaven.py b/deephaven_ipywidgets/deephaven.py index 0aafead..49a19aa 100644 --- a/deephaven_ipywidgets/deephaven.py +++ b/deephaven_ipywidgets/deephaven.py @@ -14,7 +14,6 @@ from ipywidgets import DOMWidget from traitlets import Unicode, Integer, Bytes, Bool -from deephaven_server import Server from uuid import uuid4 from ._frontend import module_name, module_version import os @@ -145,6 +144,7 @@ def __init__(self, deephaven_object, height=600, width=0, session=None): session.bind_table(object_id, deephaven_object) else: + from deephaven_server import Server port = Server.instance.port server_url = f"http://localhost:{port}/" diff --git a/setup.py b/setup.py index 124ae81..18e1000 100644 --- a/setup.py +++ b/setup.py @@ -93,7 +93,7 @@ ], include_package_data=True, python_requires=">=3.6", - install_requires=["ipywidgets>=8.0.0,<9", "deephaven-server>=0.31.0"], + install_requires=["ipywidgets>=8.0.0,<9"], extras_require={ "test": [ "pytest>=4.6", @@ -102,6 +102,8 @@ ], "examples": [ # Any requirements for the examples to run + "deephaven-server>=0.31.0", + "pydeephaven", ], "docs": [ "jupyter_sphinx", @@ -113,6 +115,12 @@ "sphinx>=1.5", "sphinx_rtd_theme", ], + "server": [ + "deephaven-server>=0.31.0", + ], + "client": [ + "pydeephaven" + ] }, entry_points={}, ) From 02801c2657a83bb1d9cd229046f6f897903f3744 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 29 Jul 2024 08:39:17 -0500 Subject: [PATCH 2/3] Update README.md Co-authored-by: Mike Bender --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e165d9..9a83566 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Deephaven Community IPython Widget Library You can install using `pip`. -If running with the embedded server, install with the following: +If running with the embedded server (`deephaven-server`), install with the following: ```shell pip install "deephaven-ipywidgets[server]" ``` From eab0726da6885972c05a9fd01580ea6b0779165b Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 29 Jul 2024 08:39:23 -0500 Subject: [PATCH 3/3] Update README.md Co-authored-by: Mike Bender --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a83566..1a0b1d2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ pip install "deephaven-ipywidgets[server]" ``` This installs the embedded server. -If connecting to a server running elsewhere, install with the following: +If connecting to a server running elsewhere (`pydeephaven`), install with the following: ```bash pip install "deephaven-ipywidgets[client]" ```