Skip to main content

DateTime input plugin for Deephaven

Project description

deephaven-plugin-datetimeinput

This is a Python plugin for Deephaven generated from a deephaven-plugin template.

Specifically, this plugin is a date-time input plugin, accept input of a date-time down to the nanosecond.

Installing the Plugin

The plugin can be installed into a Deephaven instance with pip install deephaven-plugin-datetimeinput. To install Deephaven and this plugin in your development environment:

pip install deephaven-server deephaven-plugin-datetimeinput
deephaven server

See the plug-in documentation for more information.

Using the Plugin

Once the Deephaven server is running, the plugin should be available to use.

from deephaven_plugin_datetimeinput import DateTimeInput

dti = DateTimeInput(on_change=print)

A panel should appear. If you make changes in the input, they should get printed to your console.

For a more complete example where you filter a table using the date inputted:

import datetime
from deephaven import time_table, ui
from deephaven_plugin_datetimeinput import DateTimeInput

# Create some dates and a time table that goes back in time one year
now = datetime.datetime.now()
one_year_earlier = now - datetime.timedelta(days=365)
_tt = time_table("PT1s", start_time=one_year_earlier)

# Create a component that uses the `DateTimeInput` to filter a
@ui.component
def ui_time_filter_table(source):
  date, set_date = ui.use_state('2024-05-21T12:00:00.000000000 America/Toronto')

  return [
    DateTimeInput(on_change=set_date, default_value=date),
    source.where(f"Timestamp > '{date}'")
  ]

tft = ui_time_filter_table(_tt)

Development

Plugin Structure

The src directory contains the Python and JavaScript code for the plugin. Within the src directory, the deephaven_plugin_datetimeinput directory contains the Python code, and the js directory contains the JavaScript code.

The Python files have the following structure: deephaven_plugin_datetimeinput_object.py defines a simple Python class that can send messages to the client. deephaven_plugin_datetimeinput_type.py defines the Python type for the plugin (which is used for registration) and a simple message stream. js_plugin.py defines the Python class that will be used to setup the JavaScript side of the plugin. register.py registers the plugin with Deephaven.

The JavaScript files have the following structure: DeephavenPluginDateTimeInputPlugin.ts registers the plugin with Deephaven. DeephavenPluginDateTimeInputView.tsx defines the plugin panel and message handling.

Additionally, the test directory contains Python tests for the plugin. This demonstrates how the embedded Deephaven server can be used in tests. It's recommended to use tox to run the tests, and the tox.ini file is included in the project.

Building the Plugin

To build the plugin, you will need npm and python installed, as well as the build package for Python. nvm is also strongly recommended, and an .nvmrc file is included in the project. The python venv can be created and the recommended packages installed with the following commands:

cd deephaven_plugin_datetimeinput
python -m venv .venv
source .venv/bin/activate
pip install --upgrade -r requirements.txt

Build the JavaScript plugin from the src/js directory:

cd src/js
nvm install
npm install
npm run build

Then, build the Python plugin from the top-level directory:

cd ../..
python -m build --wheel

The built wheel file will be located in the dist directory.

Installing the Development Plugin

The plugin can be installed into a Deephaven instance with pip install <wheel file>. The wheel file is stored in the dist directory after building the plugin. Exactly how this is done will depend on how you are running Deephaven. If using the venv created above, the plugin and server can be created with the following commands:

pip install deephaven-server
pip install dist/deephaven_plugin_datetimeinput-0.0.1.dev0-py3-none-any.whl --force-reinstall
deephaven server

See the plug-in documentation for more information.

Distributing the Plugin

To distribute the plugin, you can upload the wheel file to a package repository, such as PyPI. The version of the plugin can be updated in the setup.cfg file.

There is a separate instance of PyPI for testing purposes. Start by creating an account at TestPyPI. Then, get an API token from account management, setting the “Scope” to “Entire account”.

To upload to the test instance, use the following commands:

python -m pip install --upgrade twine
python -m twine upload --repository testpypi dist/*

Now, you can install the plugin from the test instance. The extra index is needed to find dependencies:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ deephaven_plugin_datetimeinput

For a production release, create an account at PyPI. Then, get an API token from account management, setting the “Scope” to “Entire account”.

To upload to the production instance, use the following commands. Note that --repository is the production instance by default, so it can be omitted:

python -m pip install --upgrade twine
python -m twine upload dist/*

Now, you can install the plugin from the production instance:

pip install deephaven_plugin_datetimeinput

See the Python packaging documentation for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file deephaven_plugin_datetimeinput-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for deephaven_plugin_datetimeinput-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e1ebabd77a95897915622e13dee10217715b51a89c2405ea4ef601c4f1f138e
MD5 b3c9bb0d581d6f24f84cc545a0b72845
BLAKE2b-256 9b01d26f6b5939159bbbba70c6d040e72b01502921f4efabf2274d88d9e088da

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page