You asked. We listened.
We have had many user requests for a simplified way to use Deephaven without Docker. Now, as of Deephaven v0.14.0
, you can install Deephaven using pip. First, you will need Java 11+ installed and the JAVA_HOME
environment variable set appropriately. Next, install deephaven-server
using pip:
pip3 install --upgrade pip setuptools wheel
pip3 install deephaven-server
Withdeephaven-server
installed, let’s create an example.py
script:
from deephaven_server import Server
s = Server(port=10000, jvm_args=["-Xmx4g"])
s.start()
from deephaven import time_table
from deephaven import ugp
with ugp.shared_lock():
t = time_table("00:00:01").update("A = i%2==0 ? `A` : `B`")
t_last = t.last_by("A")
t_join = t.natural_join(t_last, on="A", joins=["LastTime=Timestamp"])
print(t_join)
You can run this script from the command line. Here interactive mode (-i
) is used to keep the Python session up so that we can continue interacting with the Deephaven session after the script executes.
Now that your script is running in Deephaven, you can enter commands on the command line, or you can connect to the Deephaven IDE by going to http://localhost:10000/ide/ in your local web browser.
In the example above, note that the Update Graph Processor (UGP) lock must be acquired before executing many Deephaven table operations. In Deephaven, the UGP ensures that when queries are updated in real time, the calculations are all updated consistently. This lock is automatically acquired when executing a block of code in the Deephaven IDE. Python scripts not executed through the IDE must acquire the lock.
When interactively developing Deephaven code or exploring data in the Python interpreter, you may not want to think about locking. Fortunately, auto-locking has your back. When auto-locking is enabled, UGP locks are automatically acquired when they are needed. Auto-locking is enabled by default.
from deephaven_server import Server
s = Server(port=10000, jvm_args=["-Xmx4g"])
s.start()
from deephaven import time_table
t = time_table("00:00:01").update("A = i%2==0 ? `A` : `B`")
t_last = t.last_by("A")
t_join = t.natural_join(t_last, on="A", joins=["LastTime=Timestamp"])
print(t_join)
Auto-locking is very finely grained. Each table operation is locked independently. Explicit UGP locking allows more complex locking. For example, with an explicit UGP lock, multiple tables can be initialized against the same initial data set before being allowed to update. If auto-locking is enabled, explicit-locking can still be used to handle more complex cases, providing both ease of use and explicit control.
As of today, pip-installed Deephaven works for AMD64 and ARM64 Linux as well as Windows WSL. Support for more architectures and operating systems will appear in the coming months. In the meantime, unsupported architectures can use pip-installed Deephaven in a Docker container. To do this, simply create a Dockerfile
.
FROM python:3.7-bullseye
RUN apt update &&
apt install -y openjdk-11-jdk
RUN python -m pip install --upgrade pip setuptools wheel &&
pip install deephaven-server==0.14.0
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
Then build a Docker image for either linux/amd64
or linux/arm64
(Mac M1 or M2).
docker build . -t deephaven-pip-installed
If there is an architecture or operating system you want to see, tell us on Slack.
Source link
lol