Skip to content

Commit 2117781

Browse files
authored
Merge pull request #3780 from plotly/v4.2
Merge backends and websockets callbacks for 4.2
2 parents a81f4e8 + 5b2088c commit 2117781

76 files changed

Lines changed: 8594 additions & 575 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ai/ARCHITECTURE.md

Lines changed: 317 additions & 6 deletions
Large diffs are not rendered by default.

.ai/COMMANDS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ pip install -e .[ci,dev,testing,celery,diskcache]
1414
npm ci
1515
```
1616

17+
### Optional Backend Dependencies
18+
19+
```bash
20+
# For Quart backend (ASGI async)
21+
pip install dash[quart]
22+
23+
# For FastAPI backend (ASGI async)
24+
pip install dash[fastapi]
25+
26+
# For async callbacks with Flask
27+
pip install dash[async]
28+
```
29+
1730
## Building
1831

1932
```bash

.github/workflows/testing.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ jobs:
1616
outputs:
1717
table_paths_changed: ${{ steps.filter.outputs.table_related_paths }}
1818
background_cb_changed: ${{ steps.filter.outputs.background_paths }}
19+
backend_cb_changed: ${{ steps.filter.outputs.backend_paths }}
1920
dcc_paths_changed: ${{ steps.filter.outputs.dcc_related_paths }}
2021
html_paths_changed: ${{ steps.filter.outputs.html_related_paths }}
22+
websocket_changed: ${{ steps.filter.outputs.websocket_paths }}
2123
steps:
2224
- name: Checkout repository
2325
uses: actions/checkout@v4
@@ -44,6 +46,21 @@ jobs:
4446
- 'tests/background_callback/**'
4547
- 'tests/async_tests/**'
4648
- 'requirements/**'
49+
backend_paths:
50+
- 'dash/backends/**'
51+
- 'tests/backend_tests/**'
52+
websocket_paths:
53+
- 'dash/backends/_fastapi.py'
54+
- 'dash/backends/_quart.py'
55+
- 'dash/backends/base_server.py'
56+
- 'dash/_callback.py'
57+
- 'dash/_callback_context.py'
58+
- 'dash/_hooks.py'
59+
- 'dash/dash.py'
60+
- '@dash-websocket-worker/**'
61+
- 'dash/dash-renderer/src/**'
62+
- 'tests/websocket/**'
63+
- 'requirements/**'
4764
4865
lint-unit:
4966
name: Lint & Unit Tests (Python ${{ matrix.python-version }})
@@ -329,6 +346,80 @@ jobs:
329346
path: bgtests/test-reports/
330347
retention-days: 7
331348

349+
backend-tests:
350+
name: Run Backend Callback Tests (Python ${{ matrix.python-version }})
351+
needs: [build, changes_filter]
352+
if: |
353+
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) ||
354+
needs.changes_filter.outputs.backend_cb_changed == 'true'
355+
timeout-minutes: 30
356+
runs-on: ubuntu-latest
357+
strategy:
358+
fail-fast: false
359+
matrix:
360+
python-version: ["3.9", "3.12"]
361+
362+
services:
363+
redis:
364+
image: redis:6
365+
ports:
366+
- 6379:6379
367+
options: >-
368+
--health-cmd "redis-cli ping"
369+
--health-interval 10s
370+
--health-timeout 5s
371+
--health-retries 5
372+
373+
env:
374+
REDIS_URL: redis://localhost:6379
375+
steps:
376+
- name: Checkout repository
377+
uses: actions/checkout@v4
378+
379+
- name: Set up Node.js
380+
uses: actions/setup-node@v4
381+
with:
382+
node-version: '24'
383+
cache: 'npm'
384+
385+
- name: Install Node.js dependencies
386+
run: npm ci
387+
388+
- name: Set up Python ${{ matrix.python-version }}
389+
uses: actions/setup-python@v5
390+
with:
391+
python-version: ${{ matrix.python-version }}
392+
cache: 'pip'
393+
cache-dependency-path: requirements/*.txt
394+
395+
- name: Download built Dash packages
396+
uses: actions/download-artifact@v4
397+
with:
398+
name: dash-packages
399+
path: packages/
400+
401+
- name: Install Dash packages
402+
run: |
403+
python -m pip install --upgrade pip wheel
404+
python -m pip install "setuptools<80.0.0"
405+
find packages -name dash-*.whl -print -exec sh -c 'pip install "{}[async,ci,testing,dev,celery,diskcache,fastapi,quart]"' \;
406+
407+
- name: Setup Chrome and ChromeDriver
408+
uses: browser-actions/setup-chrome@v1
409+
with:
410+
chrome-version: stable
411+
412+
- name: Build/Setup test components
413+
run: npm run setup-tests.py
414+
415+
- name: Run Backend Callback Tests
416+
run: |
417+
mkdir bgtests
418+
cp -r tests bgtests/tests
419+
cd bgtests
420+
touch __init__.py
421+
pytest --headless --nopercyfinalize tests/backend_tests -v -s
422+
332423
table-unit:
333424
name: Table Unit/Lint Tests (Python ${{ matrix.python-version }})
334425
needs: [build, changes_filter]
@@ -451,6 +542,67 @@ jobs:
451542
path: components/dash-table/test-reports/
452543
retention-days: 7
453544

545+
websocket-tests:
546+
name: WebSocket Tests (Python ${{ matrix.python-version }})
547+
needs: [build, changes_filter]
548+
if: |
549+
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) ||
550+
needs.changes_filter.outputs.websocket_changed == 'true'
551+
timeout-minutes: 30
552+
runs-on: ubuntu-latest
553+
strategy:
554+
fail-fast: false
555+
matrix:
556+
python-version: ["3.9", "3.12"]
557+
558+
steps:
559+
- name: Checkout repository
560+
uses: actions/checkout@v4
561+
562+
- name: Set up Node.js
563+
uses: actions/setup-node@v4
564+
with:
565+
node-version: '24'
566+
cache: 'npm'
567+
568+
- name: Install Node.js dependencies
569+
run: npm ci
570+
571+
- name: Set up Python ${{ matrix.python-version }}
572+
uses: actions/setup-python@v5
573+
with:
574+
python-version: ${{ matrix.python-version }}
575+
cache: 'pip'
576+
cache-dependency-path: requirements/*.txt
577+
578+
- name: Download built Dash packages
579+
uses: actions/download-artifact@v4
580+
with:
581+
name: dash-packages
582+
path: packages/
583+
584+
- name: Install Dash packages
585+
run: |
586+
python -m pip install --upgrade pip wheel
587+
python -m pip install "setuptools<80.0.0"
588+
find packages -name dash-*.whl -print -exec sh -c 'pip install "{}[ci,testing,dev,fastapi,quart]"' \;
589+
590+
- name: Setup Chrome and ChromeDriver
591+
uses: browser-actions/setup-chrome@v1
592+
with:
593+
chrome-version: stable
594+
595+
- name: Build/Setup test components
596+
run: npm run setup-tests.py
597+
598+
- name: Run WebSocket tests
599+
run: |
600+
mkdir wstests
601+
cp -r tests wstests/tests
602+
cd wstests
603+
touch __init__.py
604+
pytest --headless --nopercyfinalize tests/websocket -v -s
605+
454606
test-main:
455607
name: Main Dash Tests (Python ${{ matrix.python-version }}, Group ${{ matrix.test-group }})
456608
needs: build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ packages/
9393
!components/dash-core-components/tests/integration/upload/upload-assets/upft001.csv
9494
!components/dash-table/tests/assets/*.csv
9595
!components/dash-table/tests/selenium/assets/*.csv
96+
dash_config.json
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Dash websocket worker
2+
3+
Worker for websocket based callbacks.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@plotly/dash-websocket-worker",
3+
"version": "1.0.0",
4+
"description": "SharedWorker for WebSocket-based Dash callbacks",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"scripts": {
8+
"build": "webpack --mode production",
9+
"build:dev": "webpack --mode development",
10+
"watch": "webpack --mode development --watch",
11+
"clean": "rm -rf dist"
12+
},
13+
"files": [
14+
"dist"
15+
],
16+
"keywords": [
17+
"dash",
18+
"websocket",
19+
"sharedworker"
20+
],
21+
"author": "Plotly",
22+
"license": "MIT",
23+
"devDependencies": {
24+
"typescript": "^5.0.0",
25+
"webpack": "^5.0.0",
26+
"webpack-cli": "^5.0.0",
27+
"ts-loader": "^9.0.0"
28+
}
29+
}

0 commit comments

Comments
 (0)