Metadata-Version: 2.4
Name: pydeephaven-ticking
Version: 41.3
Summary: The Deephaven Python Client for Ticking Tables
Home-page: https://deephaven.io/
Author: Deephaven Data Labs
Author-email: python@deephaven.io
License: Deephaven Community License Agreement Version 1.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: pydeephaven==41.3
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Deephaven Python Ticking Package

The `pydeephaven-ticking` package enables access to ticking Deephaven data from Python. It extends
the functionality of the pydeephaven package to add the ability to subscribe to tables and receive
change notifications containing added, removed, and modified data. It uses Cython to create a thin
wrapper around Deephaven's C++ library.

## Prerequisites

Before installing this library, you will need to install the Deephaven Core C++ library and the
pydeephaven python package. All three packages (Deephaven Core C++, pydeephaven, 
and pydeephaven-ticking) are present in the Deephaven Core GitHub repository. We assume you
have checked out this repository at the location specified by `${DHROOT}`.

The Deephaven C++ client (and ticking Python client) are tested regularly on Ubuntu 22.04 x86_64.
Additionally, successful tests have been run on RHEL 8 and Fedora 38 (both on x86_64).

To build on Windows, please see the file cpp-client/README-windows.md in
this repository.

## Installation

`pydeephaven-ticking` can be installed with `pip` or by building from source.

## `pip`

A Linux operating system on x86_64 architecture is required to install via `pip`.
It's recommended to install this way in a Python virtual environment (venv).

```sh
pip install pydeephaven-ticking
```

## Build from source

If building from source, `pydeephaven-ticking` also requires a working installation of the C++
client. All four packages (Deephaven Core, `pydeephaven`, `pydeephaven-ticking`, and the Deephaven 
C++ client) are present in the [deephaven-core](https://github.com/deephaven/deephaven-core) 
repository. It is assumed that you have the repository checked out at the location specified by 
`${DHROOT}`.

### Install the C++ client

First, install the Deephaven C++ client. Follow the instructions in `$DHROOT/cpp-client/README.md`.
Note the restrictions on supported platforms mentioned there. The instructions will ask you to
select a location for the installation of the C++ client library and its dependencies.

According to the C++ build instructions,
the location is specified in the `${DHCPP}` environment variable.

### Install pydeephaven

To install pydeephaven, follow the instructions in `${DHROOT}/py/client/README.md`.

These instructions will require you to create a Python venv. After installing that package,
you will continue to use that venv here.

### Build the ticking Python client

#### Install Cython in the venv

If you've exited your venv, re-activate it.

```sh
# This assumes your venv is in $HOME/py/cython
source ~/py/cython/bin/activate
```

Then run 

```sh
pip3 install cython
```

#### Build the shared library (Linux version)

```sh
cd ${DHROOT}/py/client-ticking
```

```sh
# Ensure the DHCPP environment variable is set per the instructions above
rm -rf build dist src/pydeephaven_ticking/_core.cpp # Ensure we clean the remnants of any pre-existing build.
DEEPHAVEN_VERSION=$(../../gradlew :printVersion -q) CPPFLAGS="-I${DHCPP}/include" LDFLAGS="-L${DHCPP}/lib" python3 setup.py build_ext -i
```

#### Install pydeephaven-ticking

Build the wheel with

```sh
DEEPHAVEN_VERSION=$(../../gradlew :printVersion -q) python3 setup.py bdist_wheel
```

Then install the package.
Note: the actual name of the `.whl` file may be different depending on system details.

```sh
pip3 install --force --no-deps dist/pydeephaven_ticking-<x.y>-cp310-cp310-linux_x86_64.whl
```

The `--force` flag is required to overwrite any previously-built version of the package that might
already be there. The `--no-deps` flag ensures that we are sure to refer to the `pydeephaven`
package just built from the above steps, rather than one from PyPi.

## Testing the library

### Run tests
``` shell
$ python3 -m unittest discover tests

```

### Sample Python program

Run python from the venv while in this directory, and try this sample Python program:

``` python
import pydeephaven as dh
import time
session = dh.Session() # assuming Deephaven Community Core is running locally with the default configuration
table = session.time_table(period=1000000000).update(formulas=["Col1 = i"])
listener_handle = dh.listen(table, lambda update : print(update.added()))
listener_handle.start()
# data starts printing asynchronously here
time.sleep(10)
listener_handle.stop()
session.close()
```
