Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshatJawne committed Nov 4, 2024
2 parents 0e0fe00 + 992bd33 commit e7ecbf1
Show file tree
Hide file tree
Showing 91 changed files with 3,108 additions and 224 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: npm run build -- --scope "@deephaven/js-plugin-${{ inputs.package }}"

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand All @@ -47,7 +47,7 @@ jobs:
run: python -m build --wheel --sdist plugins/${{ inputs.package }}

- name: Upload dist
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist-${{ inputs.package }}
path: plugins/${{ inputs.package }}/dist/
Expand Down
31 changes: 9 additions & 22 deletions .github/workflows/make-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

# assume that the dist artifact is already available from calling build-python-package.yml before this workflow
- name: Download dist
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-${{ inputs.package }}
path: plugins/${{ inputs.package }}/dist/
Expand All @@ -41,29 +41,16 @@ jobs:
- name: Run make_docs.py
run: python plugins/${{ inputs.package }}/make_docs.py

- name: Setup rclone
- name: Sync to the plugins folder
# pull requests should run the make_docs.py script, but not sync the docs
if: inputs.event_name == 'push'
run: |
sudo apt-get update
sudo apt-get install -y rclone
mkdir -p $HOME/.config
mkdir -p $HOME/.config/rclone
cat << EOF > $HOME/.config/rclone/rclone.conf
[plugindocs]
type = google cloud storage
service_account_file = $HOME/credentials.json
project_number = ${{ secrets.DOCS_GOOGLE_CLOUD_PROJECT_NUMBER }}
bucket_policy_only = true
EOF
echo ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }} | base64 -d > $HOME/credentials.json
- 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 }}/
uses: deephaven/salmon-sync@v1
with:
source: plugins/${{ inputs.package }}/docs/build/markdown/
destination: deephaven/deephaven-plugins/${{ inputs.package }}/${{ inputs.version }}/
project_number: ${{ secrets.DOCS_GOOGLE_CLOUD_PROJECT_NUMBER}}
bucket: ${{ vars.DOCS_GOOGLE_CLOUD_BUCKET }}
credentials: ${{ secrets.DOCS_GOOGLE_CLOUD_CREDENTIALS }}

- name: Setup gsutil auth
if: inputs.fix_mime_types == true
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/modified-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Filter paths
uses: dorny/paths-filter@v2
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pre-commit for Black and Blacken-docs
name: Pre-commit for code style and formatting checks

on:
push:
Expand All @@ -17,5 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
- uses: actions/setup-python@v5
with:
python-version: '3.8'
- uses: pre-commit/action@v3.0.1
2 changes: 1 addition & 1 deletion .github/workflows/release-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/checkout@v4

- name: Download dist
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-${{ inputs.package }}
path: plugins/${{ inputs.package }}/dist/
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/test-js-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,31 @@ jobs:
restore-keys: |
${{ runner.os }}-lintcache-
- name: Cache node modules
id: cache-node-modules
uses: actions/cache@v4
- name: Restore cached node modules
id: restore-node-modules
uses: actions/cache/restore@v4
with:
save-always: true
path: |
node_modules
plugins/**/node_modules
key: unit-node-modules-${{ hashFiles('package-lock.json')}}

- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
if: steps.restore-node-modules.outputs.cache-hit != 'true'
run: npm ci --no-audit

# Run all tests for all the packages
# Caching with the absolute path b/c Jest will make a folder in each project
# Then there's caches in all plugin folders
- name: Run Tests
run: npm run test:ci

- name: Always cache node modules
id: cache-node-modules
if: always() && steps.restore-node-modules.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.restore-node-modules.outputs.cache-primary-key }}
path: |
node_modules
plugins/**/node_modules
2 changes: 1 addition & 1 deletion .github/workflows/test-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

Expand Down
6 changes: 3 additions & 3 deletions plugins/plotly-express/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Key Features

- **Live Dataframe Support**: Direct integration with real-time Deephaven tables, allowing you to visualize and analyze data as it updates in real time.
- **Live Dataframe Support**: Direct integration with real-time Deephaven tables, allowing you to visualize and analyze data as it updates in real time, in addition to Pandas DataFrames.
- **Automatic Downsampling**: Pixel accurate automatic downsampling that reduces the number of data points displayed, ensuring smooth and responsive visualizations even with large datasets.
- **Server-Side Data Grouping and Aggregation**: Uses server-side processing capabilities to perform data grouping and aggregation directly within Deephaven query engine, enabling efficient analysis of huge datasets without requiring data transfer.
- **Plotly Express Compatibility**: Built on top of Plotly Express, the library inherits its comprehensive set of features, enabling you to create stunning and interactive visualizations effortlessly. In most cases you can directly swap `px` for `dx` for instant compatibility.
Expand Down Expand Up @@ -97,10 +97,10 @@ This page contains a collection of links to examples demonstrating different plo

## Quickstart

1. Install with Docker, use a Docker image with it already installed (`server-ui`), or pip install with:
1. Install with Docker, use a Docker image with it already installed, or pip install with:

```bash
pip install deephaven-plugin-plotly-express
pip install deephaven-plugin-plotly-express
```

2. To create a real-time plot using Deephaven Plotly Express, run the following example within Deephaven:
Expand Down
15 changes: 15 additions & 0 deletions plugins/plotly-express/docs/bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ bar_plot_smoke = dx.bar(sorted_tips, x="Day", y="TotalBill", by="Smoker")
bar_plot_sex = dx.bar(sorted_tips, x="Day", y="TotalBill", by="Sex")
```

### Frequency of categories

Visualize the frequency of categories in a column by passing to either the `x` or `y` argument.

```python
import deephaven.plot.express as dx
tips = dx.data.tips()

# count the number of occurrences of each day with a vertical bar plot
bar_plot_vertical = dx.bar(tips, x="Day")

# count the number of occurrences of each day with a horizontal bar plot
bar_plot_horizontal = dx.bar(tips, y="Day")
```

## API Reference
```{eval-rst}
.. dhautofunction:: deephaven.plot.express.bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from functools import partial
from collections.abc import Callable
from typing import Any
from pandas import DataFrame

import plotly.express as px

from deephaven.table import Table, PartitionedTable
from deephaven.execution_context import make_user_exec_ctx
import deephaven.pandas as dhpd

from ._layer import atomic_layer
from .PartitionManager import PartitionManager
Expand All @@ -21,6 +23,7 @@
HISTOGRAM_DEFAULTS,
SPREAD_GROUPS,
)
from ..types import PartitionableTableLike


def validate_common_args(args: dict) -> None:
Expand Down Expand Up @@ -252,6 +255,21 @@ def create_deephaven_figure(
)


def convert_to_table(table: PartitionableTableLike) -> Table | PartitionedTable:
"""
Convert a Dataframe to a Table if it is one
Args:
table: The PartitionableTableData to convert
Returns:
The Table or PartitionedTable
"""
if isinstance(table, DataFrame):
return dhpd.to_table(table)
return table


def process_args(
args: dict[str, Any],
groups: set[str] | None = None,
Expand All @@ -278,11 +296,13 @@ def process_args(
DeephavenFigure: The new figure
"""
use_args = locals()
orig_process_args = args_copy(use_args)
render_args = locals()
render_args["args"]["table"] = convert_to_table(render_args["args"]["table"])

orig_process_args = args_copy(render_args)
orig_process_func = lambda **local_args: create_deephaven_figure(**local_args)[0]

new_fig, table, key_column_table, update = create_deephaven_figure(**use_args)
new_fig, table, key_column_table, update = create_deephaven_figure(**render_args)

orig_process_args["args"].update(update)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

from plotly import express as px

from deephaven.table import Table

from ._private_utils import process_args
from ..shared import default_callback
from ..deephaven_figure import DeephavenFigure
from ..types import PartitionableTableLike


def area(
table: Table | None = None,
table: PartitionableTableLike,
x: str | list[str] | None = None,
y: str | list[str] | None = None,
by: str | list[str] | None = None,
Expand Down
21 changes: 18 additions & 3 deletions plugins/plotly-express/src/deephaven/plot/express/plots/bar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import Callable
import warnings

from plotly import express as px

Expand All @@ -9,10 +10,11 @@
from ._private_utils import validate_common_args, process_args
from ..shared import default_callback
from ..deephaven_figure import generate_figure, DeephavenFigure
from ..types import PartitionableTableLike


def bar(
table: Table | None = None,
table: PartitionableTableLike,
x: str | list[str] | None = None,
y: str | list[str] | None = None,
by: str | list[str] | None = None,
Expand Down Expand Up @@ -55,7 +57,9 @@ def bar(
Args:
table: A table to pull data from.
x: A column or list of columns that contain x-axis values.
If only x is specified, the y-axis values are the count of each unique x value.
y: A column or list of columns that contain y-axis values.
If only y is specified, the x-axis values are the count of each unique y value.
by: A column or list of columns that contain values to plot the figure traces by.
All values or combination of values map to a unique design. The variable
by_vars specifies which design elements are used.
Expand Down Expand Up @@ -144,7 +148,12 @@ def bar(
"""
args = locals()

return process_args(args, {"bar", "supports_lists"}, px_func=px.bar)
groups = {"bar", "supports_lists"}

if not x or not y:
groups.add("preprocess_freq")

return process_args(args, groups, px_func=px.bar)


def _bar_polar(
Expand Down Expand Up @@ -198,7 +207,7 @@ def _bar_polar(


def timeline(
table: Table | None = None,
table: PartitionableTableLike,
x_start: str | None = None,
x_end: str | None = None,
y: str | None = None,
Expand Down Expand Up @@ -386,6 +395,12 @@ def frequency_bar(
DeephavenFigure: A DeephavenFigure that contains the bar chart
"""
warnings.warn(
"This function is deprecated and will be removed in a future release. "
"Use bar with only one of x or y specified instead for identical behavior.",
DeprecationWarning,
stacklevel=2,
)

if x and y:
raise ValueError("Cannot specify both x and y")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
shared_histogram,
)
from ..deephaven_figure import DeephavenFigure

from ..shared import (
VIOLIN_DEFAULTS,
BOX_DEFAULTS,
STRIP_DEFAULTS,
HISTOGRAM_DEFAULTS,
default_callback,
)
from ..types import PartitionableTableLike


def violin(
table: Table | None = None,
table: PartitionableTableLike,
x: str | list[str] | None = None,
y: str | list[str] | None = None,
by: str | list[str] | None = None,
Expand Down Expand Up @@ -103,7 +103,7 @@ def violin(


def box(
table: Table | None = None,
table: PartitionableTableLike,
x: str | list[str] | None = None,
y: str | list[str] | None = None,
by: str | list[str] | None = None,
Expand Down Expand Up @@ -184,7 +184,7 @@ def box(


def strip(
table: Table | None = None,
table: PartitionableTableLike,
x: str | list[str] | None = None,
y: str | list[str] | None = None,
by: str | list[str] | None = None,
Expand Down Expand Up @@ -307,7 +307,7 @@ def _ecdf(


def histogram(
table: Table | None = None,
table: PartitionableTableLike,
x: str | list[str] | None = None,
y: str | list[str] | None = None,
by: str | list[str] | None = None,
Expand Down
Loading

0 comments on commit e7ecbf1

Please sign in to comment.