# deephaven-plugin-datetimeinput
This is a Python plugin for Deephaven generated from a [deephaven-plugin](https://github.com/deephaven/deephaven-plugins) 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:
```sh
pip install deephaven-server deephaven-plugin-datetimeinput
deephaven server
```
See the [plug-in documentation](https://deephaven.io/core/docs/how-to-guides/use-plugins/) for more information.
## Using the Plugin
Once the Deephaven server is running, the plugin should be available to use.
```python
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:
```python
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:
```sh
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:
```sh
cd src/js
nvm install
npm install
npm run build
```
Then, build the Python plugin from the top-level directory:
```sh
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:
```sh
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](https://deephaven.io/core/docs/how-to-guides/use-plugins/) for more information.
## Distributing the Plugin
To distribute the plugin, you can upload the wheel file to a package repository, such as [PyPI](https://pypi.org/).
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](https://test.pypi.org/account/register/).
Then, get an API token from [account management](https://test.pypi.org/manage/account/#api-tokens), setting the “Scope” to “Entire account”.
To upload to the test instance, use the following commands:
```sh
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:
```sh
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](https://pypi.org/account/register/).
Then, get an API token from [account management](https://pypi.org/manage/account/#api-tokens), 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:
```sh
python -m pip install --upgrade twine
python -m twine upload dist/*
```
Now, you can install the plugin from the production instance:
```sh
pip install deephaven_plugin_datetimeinput
```
See the [Python packaging documentation](https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives) for more information.
Raw data
{
"_id": null,
"home_page": null,
"name": "deephaven-plugin-datetimeinput",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "deephaven, plugin, deephaven-plugin, datetime, time, date, nanosecond",
"author": "Deephaven Data Labs",
"author_email": "mikebender@deephaven.io",
"download_url": null,
"platform": "any",
"description": "# deephaven-plugin-datetimeinput\n\nThis is a Python plugin for Deephaven generated from a [deephaven-plugin](https://github.com/deephaven/deephaven-plugins) template.\n\nSpecifically, this plugin is a date-time input plugin, accept input of a date-time down to the nanosecond.\n\n## Installing the Plugin\n\nThe plugin can be installed into a Deephaven instance with `pip install deephaven-plugin-datetimeinput`. To install Deephaven and this plugin in your development environment:\n\n```sh\npip install deephaven-server deephaven-plugin-datetimeinput\ndeephaven server\n```\n\nSee the [plug-in documentation](https://deephaven.io/core/docs/how-to-guides/use-plugins/) for more information.\n\n## Using the Plugin\n\nOnce the Deephaven server is running, the plugin should be available to use.\n\n```python\nfrom deephaven_plugin_datetimeinput import DateTimeInput\n\ndti = DateTimeInput(on_change=print)\n```\n\nA panel should appear. If you make changes in the input, they should get printed to your console.\n\nFor a more complete example where you filter a table using the date inputted:\n\n```python\nimport datetime\nfrom deephaven import time_table, ui\nfrom deephaven_plugin_datetimeinput import DateTimeInput\n\n# Create some dates and a time table that goes back in time one year\nnow = datetime.datetime.now()\none_year_earlier = now - datetime.timedelta(days=365)\n_tt = time_table(\"PT1s\", start_time=one_year_earlier)\n\n# Create a component that uses the `DateTimeInput` to filter a\n@ui.component\ndef ui_time_filter_table(source):\n date, set_date = ui.use_state('2024-05-21T12:00:00.000000000 America/Toronto')\n\n return [\n DateTimeInput(on_change=set_date, default_value=date),\n source.where(f\"Timestamp > '{date}'\")\n ]\n\ntft = ui_time_filter_table(_tt)\n```\n\n# Development\n\n## Plugin Structure\n\nThe `src` directory contains the Python and JavaScript code for the plugin.\nWithin the `src` directory, the deephaven_plugin_datetimeinput directory contains the Python code, and the `js` directory contains the JavaScript code.\n\nThe Python files have the following structure:\n`deephaven_plugin_datetimeinput_object.py` defines a simple Python class that can send messages to the client.\n`deephaven_plugin_datetimeinput_type.py` defines the Python type for the plugin (which is used for registration) and a simple message stream.\n`js_plugin.py` defines the Python class that will be used to setup the JavaScript side of the plugin.\n`register.py` registers the plugin with Deephaven.\n\nThe JavaScript files have the following structure:\n`DeephavenPluginDateTimeInputPlugin.ts` registers the plugin with Deephaven.\n`DeephavenPluginDateTimeInputView.tsx` defines the plugin panel and message handling.\n\nAdditionally, the `test` directory contains Python tests for the plugin. This demonstrates how the embedded Deephaven server can be used in tests.\nIt's recommended to use `tox` to run the tests, and the `tox.ini` file is included in the project.\n\n## Building the Plugin\n\nTo build the plugin, you will need `npm` and `python` installed, as well as the `build` package for Python.\n`nvm` is also strongly recommended, and an `.nvmrc` file is included in the project.\nThe python venv can be created and the recommended packages installed with the following commands:\n\n```sh\ncd deephaven_plugin_datetimeinput\npython -m venv .venv\nsource .venv/bin/activate\npip install --upgrade -r requirements.txt\n```\n\nBuild the JavaScript plugin from the `src/js` directory:\n\n```sh\ncd src/js\nnvm install\nnpm install\nnpm run build\n```\n\nThen, build the Python plugin from the top-level directory:\n\n```sh\ncd ../..\npython -m build --wheel\n```\n\nThe built wheel file will be located in the `dist` directory.\n\n## Installing the Development Plugin\n\nThe plugin can be installed into a Deephaven instance with `pip install <wheel file>`.\nThe wheel file is stored in the `dist` directory after building the plugin.\nExactly how this is done will depend on how you are running Deephaven.\nIf using the venv created above, the plugin and server can be created with the following commands:\n\n```sh\npip install deephaven-server\npip install dist/deephaven_plugin_datetimeinput-0.0.1.dev0-py3-none-any.whl --force-reinstall\ndeephaven server\n```\n\nSee the [plug-in documentation](https://deephaven.io/core/docs/how-to-guides/use-plugins/) for more information.\n\n## Distributing the Plugin\n\nTo distribute the plugin, you can upload the wheel file to a package repository, such as [PyPI](https://pypi.org/).\nThe version of the plugin can be updated in the `setup.cfg` file.\n\nThere is a separate instance of PyPI for testing purposes.\nStart by creating an account at [TestPyPI](https://test.pypi.org/account/register/).\nThen, get an API token from [account management](https://test.pypi.org/manage/account/#api-tokens), setting the \u201cScope\u201d to \u201cEntire account\u201d.\n\nTo upload to the test instance, use the following commands:\n\n```sh\npython -m pip install --upgrade twine\npython -m twine upload --repository testpypi dist/*\n```\n\nNow, you can install the plugin from the test instance. The extra index is needed to find dependencies:\n\n```sh\npip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ deephaven_plugin_datetimeinput\n```\n\nFor a production release, create an account at [PyPI](https://pypi.org/account/register/).\nThen, get an API token from [account management](https://pypi.org/manage/account/#api-tokens), setting the \u201cScope\u201d to \u201cEntire account\u201d.\n\nTo upload to the production instance, use the following commands.\nNote that `--repository` is the production instance by default, so it can be omitted:\n\n```sh\npython -m pip install --upgrade twine\npython -m twine upload dist/*\n```\n\nNow, you can install the plugin from the production instance:\n\n```sh\npip install deephaven_plugin_datetimeinput\n```\n\nSee the [Python packaging documentation](https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives) for more information.\n",
"bugtrack_url": null,
"license": null,
"summary": "DateTime input plugin for Deephaven",
"version": "0.2.0",
"project_urls": null,
"split_keywords": [
"deephaven",
" plugin",
" deephaven-plugin",
" datetime",
" time",
" date",
" nanosecond"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9b01d26f6b5939159bbbba70c6d040e72b01502921f4efabf2274d88d9e088da",
"md5": "b3c9bb0d581d6f24f84cc545a0b72845",
"sha256": "6e1ebabd77a95897915622e13dee10217715b51a89c2405ea4ef601c4f1f138e"
},
"downloads": -1,
"filename": "deephaven_plugin_datetimeinput-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b3c9bb0d581d6f24f84cc545a0b72845",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 14530,
"upload_time": "2024-07-19T17:49:45",
"upload_time_iso_8601": "2024-07-19T17:49:45.176253Z",
"url": "https://files.pythonhosted.org/packages/9b/01/d26f6b5939159bbbba70c6d040e72b01502921f4efabf2274d88d9e088da/deephaven_plugin_datetimeinput-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-19 17:49:45",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "deephaven-plugin-datetimeinput"
}