Skip to content

Commit

Permalink
Merge branch 'main' into 708-dashboard-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanalvizo committed Sep 22, 2024
2 parents dfe9b57 + ca06eea commit 491495b
Show file tree
Hide file tree
Showing 97 changed files with 1,761 additions and 557 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build-main-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ on:
options:
- 'push'
- 'test'
fix_mime_types:
description: 'Whether to fix the mime types of the markdown files in the docs bucket. Generally this should be false.'
required: false
type: boolean
default: false
workflow_call:
inputs:
package:
Expand All @@ -37,6 +42,11 @@ on:
description: The event name that triggered the workflow
required: true
type: string
fix_mime_types:
description: 'Whether to fix the mime types of the markdown files in the docs bucket. Generally this should be false.'
required: false
type: boolean
default: false

jobs:
check-make-docs:
Expand Down Expand Up @@ -68,3 +78,5 @@ jobs:
package: ${{ inputs.package }}
version: ${{ inputs.version }}
event_name: ${{ inputs.event_name }}
fix_mime_types: ${{ inputs.fix_mime_types }}

19 changes: 19 additions & 0 deletions .github/workflows/make-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
required: false
type: string
default: 'push'
fix_mime_types:
required: false
type: boolean
default: false

jobs:
make-docs:
Expand Down Expand Up @@ -60,3 +64,18 @@ jobs:
- name: Sync docs
if: inputs.event_name == 'push'
run: rclone sync plugins/${{ inputs.package }}/docs/build/markdown/ plugindocs:${{ secrets.DOCS_GOOGLE_CLOUD_BUCKET }}/deephaven/deephaven-plugins/${{ inputs.package }}/${{ inputs.version }}/

- name: Setup gsutil auth
if: inputs.fix_mime_types == true
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }}'

- name: Setup gsutil CLI
if: inputs.fix_mime_types == true
uses: 'google-github-actions/setup-gcloud@v2'

- name: Set gsutil markdown mime type
if: inputs.fix_mime_types == true
# some markdown files get set to octet-stream by default, so fix them
run: gsutil -m setmeta -h "Content-Type:text/markdown; charset=utf-8" -r "gs://${{ secrets.DOCS_GOOGLE_CLOUD_BUCKET }}/deephaven/deephaven-plugins/${{ inputs.package }}/${{ inputs.version }}/**/*.md"
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ repos:
plotly,
json-rpc,
matplotlib,
deephaven-plugin-utilities,
deephaven-plugin-utilities>=0.0.2,
sphinx,
click,
watchdog,
]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
- id: ruff
2 changes: 1 addition & 1 deletion plugins/matplotlib/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ install_requires =
jpy>=0.14.0
deephaven-plugin>=0.5.0
matplotlib
deephaven-plugin-utilities
deephaven-plugin-utilities>=0.0.2
include_package_data = True

[options.extras_require]
Expand Down
32 changes: 0 additions & 32 deletions plugins/matplotlib/src/deephaven/plugin/matplotlib/_js_plugin.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
import matplotlib.pyplot as plt
from deephaven.plugin import Registration, Callback
from deephaven.plugin.utilities import create_js_plugin, DheSafeCallbackWrapper
from ._js_plugin import MatplotlibJsPlugin

PACKAGE_NAMESPACE = "deephaven.plugin.matplotlib"
JS_NAME = "_js"
PLUGIN_CLASS = MatplotlibJsPlugin


def _init_theme():
Expand All @@ -30,10 +28,6 @@ def register_into(cls, callback: Callback) -> None:

callback.register(figure_type.FigureType)

js_plugin = create_js_plugin(
PACKAGE_NAMESPACE,
JS_NAME,
PLUGIN_CLASS,
)
js_plugin = create_js_plugin(PACKAGE_NAMESPACE, JS_NAME)

callback.register(js_plugin)
2 changes: 1 addition & 1 deletion plugins/plotly-express/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install_requires =
deephaven-core>=0.36.0
deephaven-plugin>=0.6.0
plotly
deephaven-plugin-utilities
deephaven-plugin-utilities>=0.0.2
include_package_data = True

[options.packages.find]
Expand Down
32 changes: 0 additions & 32 deletions plugins/plotly-express/src/deephaven/plot/express/_js_plugin.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
from deephaven.plugin import Registration, Callback
from deephaven.plugin.utilities import create_js_plugin, DheSafeCallbackWrapper
from . import DeephavenFigureType
from ._js_plugin import ExpressJsPlugin

PACKAGE_NAMESPACE = "deephaven.plot.express"
JS_NAME = "_js"
PLUGIN_CLASS = ExpressJsPlugin


class ExpressRegistration(Registration):
Expand All @@ -31,10 +29,6 @@ def register_into(cls, callback: Callback) -> None:

callback.register(DeephavenFigureType)

js_plugin = create_js_plugin(
PACKAGE_NAMESPACE,
JS_NAME,
PLUGIN_CLASS,
)
js_plugin = create_js_plugin(PACKAGE_NAMESPACE, JS_NAME)

callback.register(js_plugin)
131 changes: 0 additions & 131 deletions plugins/ui/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1325,137 +1325,6 @@ def multiwave():
mw = multiwave()
```

## Using ui.table

You can use `ui.table` to add interactivity to a table, or give other instructions to the UI. Here's an example that creates two tables and a plot. The first table, `t1`, is an unfiltered view of the stocks table, with a row double-press listener so if you double-click on a row, it will filter the second table, `t2`, to show that row only and the plot to show that selected sym and exchange.

```py
from deephaven import ui
from deephaven.plot.figure import Figure
import deephaven.plot.express as dx

stocks = dx.data.stocks()


@ui.component
def stock_table_input(source, default_sym="", default_exchange=""):
sym, set_sym = ui.use_state(default_sym)
exchange, set_exchange = ui.use_state(default_exchange)

t1 = source
t2 = source.where([f"Sym=`{sym.upper()}`", f"Exchange=`{exchange}`"])
p = (
Figure()
.plot_xy(series_name=f"{sym}-{exchange}", t=t2, x="Timestamp", y="Price")
.show()
)

def handle_row_double_press(data):
set_sym(data["Sym"]["value"])
set_exchange(data["Exchange"]["value"])

return [
ui.panel(
ui.table(t1, on_row_double_press=handle_row_double_press),
title="Stock Table Input",
),
ui.panel(t2, title="Stock Filtered Table"),
ui.panel(p, title="Stock Plot"),
]


sti = stock_table_input(stocks, "CAT", "TPET")
```

### ui.table Events

The `ui.table` component has a few events that you can listen to. You can listen to different kinds of press events that include the data about the region pressed.

```py
from deephaven import ui
import deephaven.plot.express as dx

te = ui.table(
dx.data.stocks(),
on_row_press=lambda row, data: print(f"Row Press: {row}, {data}"),
on_row_double_press=lambda row, data: print(f"Row Double Press: {row}, {data}"),
on_cell_press=lambda cell_index, data: print(f"Cell Press: {cell_index}, {data}"),
on_cell_double_press=lambda cell_index, data: print(
f"Cell Double Press: {cell_index}, {data}"
),
on_column_press=lambda column: print(f"Column Press: {column}"),
on_column_double_press=lambda column: print(f"Column Double Press: {column}"),
)
```

![Table events](_assets/table_events.png)

### ui.table Context Menu

Items can be added to the bottom of the `ui.table` context menu (right-click menu) by using the `context_menu` or `context_header_menu` props. The `context_menu` prop adds items to the cell context menu, while the `context_header_menu` prop adds items to the column header context menu.

Menu items must have a `title` and either an `action` or `actions` prop. They may have an `icon` which is the name of the icon that will be passed to `ui.icon`.

The `action` prop is a callback that is called when the item is clicked and receives info about the cell that was clicked when the menu was opened.

The `actions` prop is an array of menu items that will be displayed in a sub-menu. Sub-menus can contain other sub-menus for a nested menu.

Menu items can be dynamically created by instead passing a function as the context item. The function will be called with the data of the cell that was clicked when the menu was opened, and must return the menu items or None.

```py
from deephaven import ui
import deephaven.plot.express as dx

t = ui.table(
dx.data.stocks(),
context_menu=[
{
"title": "Context item",
"icon": "dhTruck",
"action": lambda d: print("Context item", d)
},
{
"title": "Nested menu",
"actions": [
{
"title": "Nested item 1",
"action": lambda d: print("Nested item 1", d)
},
{
"title": "Nested item 2",
"icon": "vsCheck",
"action": lambda d: print("Nested item 2", d)
}
]
}
],
context_header_menu={
"title": "Header context menu item",
"action": lambda d: print("Header context menu item", d)
}
)
```

The following example shows creating context menu items dynamically so that the item only appears on the `sym` column. If multiple functions are passed in a list, each will be called and any items they return will be added to the context menu.

```py
from deephaven import ui
import deephaven.plot.express as dx

def create_context_menu(data):
if data["column_name"] == "Sym":
return {
"title": f"Print {data['value']}",
"action": lambda d: print(d['value'])
}
return None

t = ui.table(
dx.data.stocks(),
context_menu=create_context_menu
)
```

## Re-using components

In a previous example, we created a text_filter_table component. We can re-use that component, and display two tables with an input filter side-by-side:
Expand Down
Binary file added plugins/ui/docs/_assets/table_column_groups.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugins/ui/docs/_assets/table_column_order.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed plugins/ui/docs/_assets/table_events.png
Binary file not shown.
Binary file added plugins/ui/docs/_assets/table_quick_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions plugins/ui/docs/components/slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Sliders allow users to quickly select a value within a fixed range and should be
```python
from deephaven import ui


my_slider_basic = ui.slider(default_value=12, label="Cookies to buy")
```

Expand Down
Loading

0 comments on commit 491495b

Please sign in to comment.