Skip to content

Update to JupyterLite 0.6.0 #791

@jtpio

Description

@jtpio

Opening an issue to track the update to the next JupyterLite 0.6.0 version, currently in alpha.

With jupyterlite/jupyterlite#1590, JupyterLite simplifies its code base and the way plugins are being loaded.

For thebe that would mean updating the use of @jupyterlite/server-extension and how "server" extensions are being loaded.

Doing a quick search on the code base leads to the following places, for example:

"@jupyterlite/server": "0.4.5",
"@jupyterlite/server-extension": "0.4.5",

export async function startJupyterLiteServer(config?: LiteServerConfig): Promise<ServiceManager> {
/**
* This is sufficent to initialise the global object?
*/
PageConfig.getOption('');
/**
* Do not rely on a configuration being on the document body, accept configuration via arguments
* and set options on the page config directly
*/
const defaultLiteConfig = {
litePluginSettings: {
'@jupyterlite/pyodide-kernel-extension:kernel': {
pipliteUrls: ['https://unpkg.com/@jupyterlite/[email protected]/pypi/all.json'],
pipliteWheelUrl:
'https://unpkg.com/@jupyterlite/[email protected]/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
*
* liteExtension - essential, as these are how kernels are added
* federatedExtension - general jupyterlab extensions
* federatedMimeExtension - render extensions? e.g. @jupyterlab/javascript-extension, @jupyterlab/json-extension
* federatedStyles - ?
*
* TODO we're not suppporting all of these yet
*/
const litePluginsToRegister: JupyterLiteServer.IPluginModule[] = [];
// Add the base serverlite extensions
const baseServerExtensions = await Promise.all(serverExtensions);
baseServerExtensions.forEach((p) => {
for (const plugin of activePlugins(p)) {
litePluginsToRegister.push(plugin);
}
});
// TODO get federated extensions in from config argument?
const extensions: any[] = [];
const liteExtensionPromises: any[] = [import('@jupyterlite/pyodide-kernel-extension')];
extensions.forEach((data) => {
if (data.liteExtension) {
liteExtensionPromises.push(createModule(data.name, data.extension));
return;
}
});
// Add the serverlite federated extensions.
const federatedLiteExtensions = await Promise.allSettled(liteExtensionPromises);
federatedLiteExtensions.forEach((p) => {
if (p.status === 'fulfilled') {
for (const plugin of activePlugins(p.value)) {
litePluginsToRegister.push(plugin);
}
} else {
console.error(p.reason);
}
});
// create the in-browser JupyterLite Server
const jupyterLiteServer = new JupyterLiteServer({} as any);
jupyterLiteServer.registerPluginModules(litePluginsToRegister);
// start the server
await jupyterLiteServer.start();
const { serviceManager } = jupyterLiteServer;
await serviceManager.ready;
// TODO
return serviceManager as unknown as ServiceManager;
}

There is already a migration guide available here, which should highlight the major changes: https://jupyterlite.readthedocs.io/en/latest/migration.html#to-0-6-0.

The latest 0.6.0a3 includes this change and is now available: https://github.com/jupyterlite/jupyterlite/releases/tag/v0.6.0a3

I'll see if I can find some time to look into updating thebe during the JupyterLite 0.6.0 pre-release phase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions