Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 78 additions & 78 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/ui/docs/components/combo_box.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Recommendations for creating clear and effective combo boxes:

## Data sources

For combo boxes, we can use a Deephaven table as a data source to populate the options. When using a table, it automatically uses the first column as both the key and label. If there are any duplicate keys, an error will be thrown; to avoid this, a `select_distinct` can be used on the table prior to using it as a combo box data source.
For combo boxes, we can use a Deephaven table or [URI](uri.md) as a data source to populate the options. When using a table, it automatically uses the first column as both the key and label. If there are any duplicate keys, an error will be thrown; to avoid this, a `select_distinct` can be used on the table prior to using it as a combo box data source.

```python order=my_combo_box_table_source_example,countries
from deephaven import ui, empty_table
Expand Down
2 changes: 1 addition & 1 deletion plugins/ui/docs/components/list_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ my_list_view = ui_list_view()

## Table Source Example

List view items can also be generated from a table directly or using `item_table_source`.
List view items can also be generated from a table or [URI](uri.md) directly or using `item_table_source`.

### Passing Table Directly

Expand Down
2 changes: 1 addition & 1 deletion plugins/ui/docs/components/picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Recommendations for creating pickers:

## Data sources

We can use a Deephaven table as a data source to populate the options for pickers. A table automatically uses the first column as both the key and label. If there are duplicate keys, an error will be thrown; to avoid this, a `select_distinct` can be used on the table before using it as a picker data source.
We can use a Deephaven table or [URI](uri.md) as a data source to populate the options for pickers. A table automatically uses the first column as both the key and label. If there are duplicate keys, an error will be thrown; to avoid this, a `select_distinct` can be used on the table before using it as a picker data source.

```python order=my_picker_table_source_example,stocks
from deephaven import ui
Expand Down
4 changes: 4 additions & 0 deletions plugins/ui/docs/components/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ t = ui.table(_t)
2. Use a UI table to show properties like filters as if the user had created them in the UI. Users can change the default values provided by the UI table, such as filters.
3. UI tables handle ticking tables automatically, so you can pass any Deephaven table to a UI table.

## Table data source

The first argument to `ui.table` is the table data source. This can be any Deephaven table, a URI to a table, or a string which will be resolved as a URI. See the [URI Element](uri.md) documentation for more information on how to use URIs with UI elements.

## Formatting

You can format the table using the `format_` prop. This prop takes a `ui.TableFormmat` object or list of `ui.TableFormat` objects. `ui.TableFormat` is a dataclass that encapsulates the formatting options for a table. The full list of formatting options can be found in the [API Reference](#tableformat).
Expand Down
74 changes: 74 additions & 0 deletions plugins/ui/docs/components/uri.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# URI

URIs are a way to reference Deephaven resources, such as tables or figures, from another instance. Deephaven UI has its own `ui.resolve` method that does not require server-to-server communication. Instead, the web client communicates directly with the appropriate server to get the resource.

## Usage

Deephaven UI provides a `resolve` method (not to be confused with the `resolve` method from the [Deephaven URI package](/core/pydoc/code/deephaven.uri.html)) that allows you to reference Deephaven resources from other instances. Unlike the Deephaven URI package, `ui.resolve` does not resolve the URI to its resource on the server, so you cannot apply operations to the resource.

> [!NOTE]
> Currently, the only valid URIs for Deephaven UI are for Deephaven Enterprise Persistent Queries.
> See the [Deephaven Enterprise documentation](/enterprise/docs/deephaven-database/remote-tables-python/#uris) for more information on Persistent Query URIs. The optional parameters are ignored by `ui.resolve`.

### Plain references

One way to use `ui.resolve` is to assign the reference to a variable, which the web UI will open just as if you created the resource. This can be useful if you want to display tables from multiple sources in a single dashboard without the worker defining the dashboard pulling the data from each source.

```py order=null
from deephaven import ui

t = ui.resolve("pq://MyPersistentQuery/scope/table") # Can't do t.update() or any other operations
p = ui.resolve("pq://MyPersistentQuery/scope/plot")


@ui.component
def basic_dashboard():
return ui.panel(ui.flex(t, p), title="Table and Plot")


my_dashboard = ui.dashboard(basic_dashboard())
```

### Usage in UI components

Some Deephaven UI components that accept tables as sources can also accept URIs. This includes [`ui.table`](table.md) and any components that accept an `item_table_source`. When using a URI with UI components, you can often just use the string without needing to call `ui.resolve`. However, if a component may take a string as a valid child (e.g., `ui.picker`), then you must use `ui.resolve` to distinguish between a string and a URI. You can always use `ui.resolve` in places where you can use just the string if you prefer to be explicit.

> [!WARNING]
> Deephaven UI URIs cannot be used as table sources in the Deephaven Express plotting library.

```py order=null
from deephaven import ui

# You can use any ui.table props with a URI source
t = ui.table(
"pq://MyPersistentQuery/scope/table",
format_=ui.TableFormat(cols="A", background_color="salmon")
)

# Must use ui.resolve because string is a valid child
picker = ui.picker(
ui.resolve("pq://MyPersistentQuery/scope/picker_table"),
label="Picker Table"
)

list_view = ui.list_view(
ui.item_table_source(
"pq://MyPersistentQuery/scope/list_view_table",
key_column="Keys",
label_column="Labels"
)
)
```

## URI Encoding

If your URI contains any special characters, such as spaces or slashes, you must encode the URI components using standard URL encoding. This is because URIs are often used in web contexts where special characters can cause issues. You can use Python's built-in `urllib.parse.quote` function to encode your URIs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixed feelings here... should we be explaining this on the Core side? Or on the Enterprise side? We really should have a utility method that accepts the query name and object name to make the URI for you, with proper encoding, ui.query_resolve or something, e.g. ui.query_resolve(query="MyQueryName", widget="MyWidget"). Technically it'd be Core+ only, but I wouldn't feel terrible about putting it in Core anyways...

As for this part - "If your URI contains any special characters" - moreso should be "You can construct a URI with any query name. If your query name contains special characters, such as spaces or slashes, you must encode the name first to avoid mangling the URL". (But nicer)


```py order=null
from urllib.parse import quote
from deephaven import ui

# Encode the URI
pq_name = quote("My PQ/with spaces!", safe="") # safe="" will encode the forward slash
t = ui.resolve(f"pq://{pq_name}/scope/table")
```
Loading
Loading