Skip to content

Commit 2200a24

Browse files
committed
widgets: got bqplot to mostly work... but had to temporarily disable buffer update
1 parent ba9d58b commit 2200a24

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/packages/frontend/jupyter/widgets/manager2.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ export class WidgetManager {
239239
A simple example that uses buffers is this image one:
240240
https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html#image
241241
*/
242+
243+
console.log("TEMPORARILY skipping buffers change!!");
244+
return;
245+
242246
const model = await this.manager.get_model(model_id);
243247
const { buffer_paths, buffers } =
244248
await this.ipywidgets_state.get_model_buffers(model_id);
@@ -249,13 +253,15 @@ export class WidgetManager {
249253
for (let i = 0; i < buffer_paths.length; i++) {
250254
// TODO/concern: what if buffer_paths is deeper (length > 1)?
251255
// Will that break something? We do set things properly later.
252-
const buffer = buffers[i];
253256
const key = buffer_paths[i][0];
254-
const value =
255-
serializers[key]?.serialize({ buffer, ...deserialized_state[key] }) ??
256-
deserialized_state[key] ??
257-
null; // must be null, not undefined, so can json.
258-
change[key] = value;
257+
if (deserialized_state[key] == null) {
258+
change[key] = null;
259+
continue;
260+
}
261+
const buffer = buffers[i];
262+
const s = serializers[key]?.serialize(deserialized_state[key]) ?? {};
263+
s.value = { buffer };
264+
change[key] = s;
259265
}
260266
log("handleBuffersChange: ", model_id, change);
261267
model.set_state(change);
@@ -412,7 +418,7 @@ export class WidgetManager {
412418
return await this.manager.get_model(model_id);
413419
};
414420

415-
private dereferenceModelLinks = async (state): Promise<boolean> => {
421+
dereferenceModelLinks = async (state): Promise<boolean> => {
416422
// log("dereferenceModelLinks", "BEFORE", state);
417423
for (const key in state) {
418424
const val = state[key];
@@ -568,6 +574,19 @@ class Environment implements WidgetEnvironment {
568574
// upstream widget manager works). This works around that.
569575
state["outputs"] = [];
570576
}
577+
const { buffer_paths, buffers } =
578+
await this.manager.ipywidgets_state.get_model_buffers(model_id);
579+
for (let i = 0; i < buffer_paths.length; i++) {
580+
// TODO/concern: what if buffer_paths is deeper (length > 1)?
581+
// Will that break something? We do set things properly later.
582+
const buffer = buffers[i];
583+
const key = buffer_paths[i][0];
584+
// TODO -- but what about deeply nested key!?
585+
// I only figured out to use value:{buffer} from looking at
586+
// the bqplot source code.
587+
state[key] = { ...state[key], value: { buffer } };
588+
}
589+
571590
setTimeout(() => this.manager.watchModel(model_id), 1);
572591
return {
573592
modelName: state._model_name,

0 commit comments

Comments
 (0)