Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix widgets disconnect #786

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/lovely-roses-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'thebe-react': minor
'thebe-lite': minor
'demo-simple': minor
---

Clients no longer have to explicitly supply `litePluginSettings` unless they explicitly want to override them. This simplifies upgrades as clients should just bump packages, and the correct plugin settings for the bundled pyodide kernel will be applied by default.
5 changes: 5 additions & 0 deletions .changeset/selfish-feet-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'thebe-lite': minor
---

Upgrading `@jupyterlite/pyodide-kernel-extension` to fix ipywidget disconnect issues.
12 changes: 0 additions & 12 deletions apps/simple/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@
}
}
</script>
<script id="jupyter-config-data" type="application/json">
{
"litePluginSettings": {
"@jupyterlite/pyodide-kernel-extension:kernel": {
"pipliteUrls": ["https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/all.json"],
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/piplite-0.4.2-py3-none-any.whl"
}
},
"enableMemoryStorage": true,
"settingsStorageDrivers": ["memoryStorageDriver"]
}
</script>
<!-- this following is the thebe entrypoint script -->
<script src="thebe-lite.min.js"></script>
<script src="index.js"></script>
Expand Down
12 changes: 0 additions & 12 deletions apps/simple/static/ipywidgets-lite.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@
useBinder: false
}
</script>
<script id="jupyter-config-data" type="application/json">
{
"litePluginSettings": {
"@jupyterlite/pyodide-kernel-extension:kernel": {
"pipliteUrls": ["https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/all.json"],
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/piplite-0.4.2-py3-none-any.whl"
}
},
"enableMemoryStorage": true,
"settingsStorageDrivers": ["memoryStorageDriver"]
}
</script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
Expand Down
12 changes: 0 additions & 12 deletions apps/simple/static/lite.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@
useBinder: false
}
</script>
<script id="jupyter-config-data" type="application/json">
{
"litePluginSettings": {
"@jupyterlite/pyodide-kernel-extension:kernel": {
"pipliteUrls": ["https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/all.json"],
"pipliteWheelUrl": "https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/piplite-0.4.2-py3-none-any.whl"
}
},
"enableMemoryStorage": true,
"settingsStorageDrivers": ["memoryStorageDriver"]
}
</script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
Expand Down
130 changes: 65 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/lite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"homepage": "https://github.com/executablebooks/thebe#readme",
"dependencies": {
"@jupyterlab/coreutils": "^6.2.5",
"@jupyterlite/pyodide-kernel": "0.4.2",
"@jupyterlite/pyodide-kernel-extension": "0.4.2",
"@jupyterlite/server": "0.4.1",
"@jupyterlite/server-extension": "0.4.1",
"@jupyterlite/pyodide-kernel": "0.4.7",
"@jupyterlite/pyodide-kernel-extension": "0.4.7",
"@jupyterlite/server": "0.4.5",
"@jupyterlite/server-extension": "0.4.5",
"hook-shell-script-webpack-plugin": "^0.1.4"
},
"devDependencies": {
Expand Down
26 changes: 23 additions & 3 deletions packages/lite/src/jlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,29 @@ export async function startJupyterLiteServer(config?: LiteServerConfig): Promise
* Do not rely on a configuration being on the document body, accept configuration via arguments
* and set options on the page config directly
*/
if (config?.litePluginSettings) {
PageConfig.setOption('litePluginSettings', JSON.stringify(config.litePluginSettings));
}
const defaultLiteConfig = {
litePluginSettings: {
'@jupyterlite/pyodide-kernel-extension:kernel': {
pipliteUrls: ['https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.7/pypi/all.json'],
pipliteWheelUrl:
'https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.7/pypi/piplite-0.4.7-py3-none-any.whl',
},
},
enableMemoryStorage: true,
settingsStorageDrivers: ['memoryStorageDriver'],
};
PageConfig.setOption(
'litePluginSettings',
JSON.stringify({ ...defaultLiteConfig.litePluginSettings, ...config?.litePluginSettings }),
);
PageConfig.setOption(
'enableMemoryStorage',
JSON.stringify(config?.enableMemoryStorage ?? defaultLiteConfig.enableMemoryStorage),
);
PageConfig.setOption(
'settingsStorageDrivers',
JSON.stringify(config?.settingsStorageDrivers ?? defaultLiteConfig.settingsStorageDrivers),
);

/**
* Seems like there are 4 different extensions we may want to handle
Expand Down
4 changes: 3 additions & 1 deletion packages/lite/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import type { ServiceManager } from '@jupyterlab/services';
*/

export type LiteServerConfig = {
litePluginSettings: Record<string, any>;
litePluginSettings?: Record<string, any>;
enableMemoryStorage?: boolean;
settingsStorageDrivers?: string[];
};

export interface ThebeLiteGlobal {
Expand Down
11 changes: 1 addition & 10 deletions packages/react/src/ThebeServerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,7 @@ export function ThebeServerProvider({
setConnecting(true);
if (customConnectFn) customConnectFn(server);
else if (useBinder) server.connectToServerViaBinder(customRepoProviders);
else if (useJupyterLite)
server.connectToJupyterLiteServer({
litePluginSettings: {
'@jupyterlite/pyodide-kernel-extension:kernel': {
pipliteUrls: ['https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/all.json'],
pipliteWheelUrl:
'https://unpkg.com/@jupyterlite/pyodide-kernel@0.4.2/pypi/piplite-0.4.2-py3-none-any.whl',
},
},
});
else if (useJupyterLite) server.connectToJupyterLiteServer();
else server.connectToJupyterServer();

server.ready.then(
Expand Down
Loading