Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add server and client specific installs #45

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand Down Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion deephaven_ipywidgets/deephaven.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}/"

Expand Down
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -102,6 +102,8 @@
],
"examples": [
# Any requirements for the examples to run
"deephaven-server>=0.31.0",
"pydeephaven",
],
"docs": [
"jupyter_sphinx",
Expand All @@ -113,6 +115,12 @@
"sphinx>=1.5",
"sphinx_rtd_theme",
],
"server": [
"deephaven-server>=0.31.0",
],
"client": [
"pydeephaven"
]
},
entry_points={},
)
Expand Down
Loading