Skip to content

Commit dda4a59

Browse files
authored
Merge branch 'dev' into feat/dynamic-loading
2 parents 9b42485 + ba22c4d commit dda4a59

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
@@ -352,7 +352,8 @@ function handleServerside(
352352
long: LongCallbackInfo | undefined,
353353
additionalArgs: [string, string, boolean?][] | undefined,
354354
getState: any,
355-
output: string
355+
output: string,
356+
running: any
356357
): Promise<CallbackResponse> {
357358
if (hooks.request_pre) {
358359
hooks.request_pre(payload);
@@ -367,6 +368,11 @@ function handleServerside(
367368
let moreArgs = additionalArgs;
368369
const libraries = Object.keys(getState().libraries);
369370

371+
if (running) {
372+
sideUpdate(running.running, dispatch, paths);
373+
runningOff = running.runningOff;
374+
}
375+
370376
const fetchCallback = () => {
371377
const headers = getCSRFHeader() as any;
372378
let url = `${urlBase(config)}_dash-update-component`;
@@ -501,12 +507,6 @@ function handleServerside(
501507
if (data.progress) {
502508
sideUpdate(data.progress, dispatch, paths);
503509
}
504-
if (data.running) {
505-
sideUpdate(data.running, dispatch, paths);
506-
}
507-
if (!runningOff && data.runningOff) {
508-
runningOff = data.runningOff;
509-
}
510510
if (!progressDefault && data.progressDefault) {
511511
progressDefault = data.progressDefault;
512512
}
@@ -754,7 +754,8 @@ export function executeCallback(
754754
long,
755755
additionalArgs.length ? additionalArgs : undefined,
756756
getState,
757-
cb.callback.output
757+
cb.callback.output,
758+
cb.callback.running
758759
);
759760

760761
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
@@ -15,6 +15,7 @@ export interface ICallbackDefinition {
1515
state: ICallbackProperty[];
1616
long?: LongCallbackInfo;
1717
dynamic_creator?: boolean;
18+
running: any;
1819
}
1920

2021
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)