diff --git a/README.md b/README.md index e42e74a..1a0b1d2 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 (`deephaven-server`), install with the following: +```shell +pip install "deephaven-ipywidgets[server]" +``` +This installs the embedded server. + +If connecting to a server running elsewhere (`pydeephaven`), 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={}, )