Skip to content

Commit e710b47

Browse files
authored
Merge branch 'dev' into update-dcc-loading
2 parents 2c0961a + ba22c4d commit e710b47

File tree

18 files changed

+224
-25
lines changed

18 files changed

+224
-25
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ max-bool-expr=5
414414
max-branches=15
415415

416416
# Maximum number of locals for function / method body
417-
max-locals=18
417+
max-locals=20
418418

419419
# Maximum number of parents for a class (see R0901).
420420
max-parents=7

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ This project adheres to [Semantic Versioning](https://semver.org/).
77
## Fixed
88

99
- [#2756](https://github.com/plotly/dash/pull/2756) Prevent false dangerous link warning. Fixes [#2743](https://github.com/plotly/dash/issues/2743)
10+
- [#2752](https://github.com/plotly/dash/pull/2752) Fixed issue with Windows build, for first time build on Windows, the dev needs to use `npm run first-build`
1011

1112
## Changed
1213

1314
- [#2734](https://github.com/plotly/dash/pull/2734) Configure CI for Python 3.10 [#1863](https://github.com/plotly/dash/issues/1863)
1415
- [#2735](https://github.com/plotly/dash/pull/2735) Configure CI for Python 3.8 and 3.12, drop support for Python 3.6 and Python 3.7 [#2736](https://github.com/plotly/dash/issues/2736)
1516

17+
## Added
18+
- [#2758](https://github.com/plotly/dash/pull/2758)
19+
- exposing `setProps` to `dash_clientside.clientSide_setProps` to allow for JS code to interact directly with the dash eco-system
20+
- [#2730](https://github.com/plotly/dash/pull/2721) Load script files with `.mjs` ending as js modules
21+
- [#2770](https://github.com/plotly/dash/pull/2770) Add running to regular callbacks.
22+
1623
## [2.15.0] - 2024-01-31
1724

1825
## Added

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ $ npm ci
2323
#
2424
$ npm run build # runs `renderer build` and `npm build` in dcc, html, table
2525
# build and install components used in tests
26+
# on windows, the developer will need to use `npm run first-build` this performs additional first steps
2627
#
2728
# Alternatively one could run part of the build process e.g.
2829
$ dash-update-components "dash-core-components"

dash/_callback.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,6 @@ def callback(
166166
"Progress and progress default needs to be of same length"
167167
)
168168

169-
if running:
170-
long_spec["running"] = coerce_to_list(running)
171-
validate_long_inputs(x[0] for x in long_spec["running"])
172-
173169
if cancel:
174170
cancel_inputs = coerce_to_list(cancel)
175171
validate_long_inputs(cancel_inputs)
@@ -188,6 +184,7 @@ def callback(
188184
**_kwargs,
189185
long=long_spec,
190186
manager=manager,
187+
running=running,
191188
)
192189

193190

@@ -227,6 +224,7 @@ def insert_callback(
227224
prevent_initial_call,
228225
long=None,
229226
manager=None,
227+
running=None,
230228
dynamic_creator=False,
231229
):
232230
if prevent_initial_call is None:
@@ -251,6 +249,8 @@ def insert_callback(
251249
},
252250
"dynamic_creator": dynamic_creator,
253251
}
252+
if running:
253+
callback_spec["running"] = running
254254

255255
callback_map[callback_id] = {
256256
"inputs": callback_spec["inputs"],
@@ -289,6 +289,14 @@ def register_callback( # pylint: disable=R0914
289289

290290
long = _kwargs.get("long")
291291
manager = _kwargs.get("manager")
292+
running = _kwargs.get("running")
293+
if running is not None:
294+
if not isinstance(running[0], (list, tuple)):
295+
running = [running]
296+
running = {
297+
"running": {str(r[0]): r[1] for r in running},
298+
"runningOff": {str(r[0]): r[2] for r in running},
299+
}
292300
allow_dynamic_callbacks = _kwargs.get("_allow_dynamic_callbacks")
293301

294302
output_indices = make_grouping_by_index(output, list(range(grouping_len(output))))
@@ -305,6 +313,7 @@ def register_callback( # pylint: disable=R0914
305313
long=long,
306314
manager=manager,
307315
dynamic_creator=allow_dynamic_callbacks,
316+
running=running,
308317
)
309318

310319
# pylint: disable=too-many-locals
@@ -389,11 +398,6 @@ def add_context(*args, **kwargs):
389398
"job": job,
390399
}
391400

392-
running = long.get("running")
393-
394-
if running:
395-
data["running"] = {str(r[0]): r[1] for r in running}
396-
data["runningOff"] = {str(r[0]): r[2] for r in running}
397401
cancel = long.get("cancel")
398402
if cancel:
399403
data["cancel"] = cancel

dash/dash-renderer/renderer-test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
file=./build/dash_renderer.min.js
3+
if [ ! -f "$file" ]; then
4+
echo "dash-renderer did not build correctly"
5+
exit 1
6+
fi

dash/dash-renderer/src/actions/callbacks.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ function handleServerside(
349349
long: LongCallbackInfo | undefined,
350350
additionalArgs: [string, string, boolean?][] | undefined,
351351
getState: any,
352-
output: string
352+
output: string,
353+
running: any
353354
): Promise<CallbackResponse> {
354355
if (hooks.request_pre) {
355356
hooks.request_pre(payload);
@@ -363,6 +364,11 @@ function handleServerside(
363364
let progressDefault: any;
364365
let moreArgs = additionalArgs;
365366

367+
if (running) {
368+
sideUpdate(running.running, dispatch, paths);
369+
runningOff = running.runningOff;
370+
}
371+
366372
const fetchCallback = () => {
367373
const headers = getCSRFHeader() as any;
368374
let url = `${urlBase(config)}_dash-update-component`;
@@ -497,12 +503,6 @@ function handleServerside(
497503
if (data.progress) {
498504
sideUpdate(data.progress, dispatch, paths);
499505
}
500-
if (data.running) {
501-
sideUpdate(data.running, dispatch, paths);
502-
}
503-
if (!runningOff && data.runningOff) {
504-
runningOff = data.runningOff;
505-
}
506506
if (!progressDefault && data.progressDefault) {
507507
progressDefault = data.progressDefault;
508508
}
@@ -717,7 +717,8 @@ export function executeCallback(
717717
long,
718718
additionalArgs.length ? additionalArgs : undefined,
719719
getState,
720-
cb.callback.output
720+
cb.callback.output,
721+
cb.callback.running
721722
);
722723

723724
if (newHeaders) {

dash/dash-renderer/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {DashRenderer} from './DashRenderer';
2+
import './utils/clientsideFunctions';
23

34
// make DashRenderer globally available
45
window.DashRenderer = DashRenderer;

dash/dash-renderer/src/store.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export default class RendererStore {
5656
private createAppStore = (reducer: any, middleware: any) => {
5757
this.__store = createStore(reducer, middleware);
5858
this.storeObserver.setStore(this.__store);
59+
const ds = ((window as any).dash_stores =
60+
(window as any).dash_stores || []);
61+
if (!ds.includes(this.__store)) {
62+
ds.push(this.__store);
63+
}
5964
this.setObservers();
6065
};
6166

dash/dash-renderer/src/types/callbacks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface ICallbackDefinition {
1313
state: ICallbackProperty[];
1414
long?: LongCallbackInfo;
1515
dynamic_creator?: boolean;
16+
running: any;
1617
}
1718

1819
export interface ICallbackProperty {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {updateProps, notifyObservers} from '../actions/index';
2+
import {getPath} from '../actions/paths';
3+
4+
const set_props = (id: string | object, props: {[k: string]: any}) => {
5+
const ds = ((window as any).dash_stores =
6+
(window as any).dash_stores || []);
7+
for (let y = 0; y < ds.length; y++) {
8+
const {dispatch, getState} = ds[y];
9+
const {paths} = getState();
10+
const componentPath = getPath(paths, id);
11+
dispatch(
12+
updateProps({
13+
props,
14+
itempath: componentPath
15+
})
16+
);
17+
dispatch(notifyObservers({id, props}));
18+
}
19+
};
20+
21+
const dc = ((window as any).dash_clientside =
22+
(window as any).dash_clientside || {});
23+
dc['set_props'] = set_props;

0 commit comments

Comments
 (0)