Skip to content

Commit

Permalink
chore: headless jupyterlab
Browse files Browse the repository at this point in the history
  • Loading branch information
echarles committed Sep 24, 2023
1 parent c3fb40b commit eb99ce8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 34 deletions.
8 changes: 0 additions & 8 deletions src/App.tsx

This file was deleted.

61 changes: 39 additions & 22 deletions src/DatalayerDev.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
import { useState } from 'react';
import { createRoot } from 'react-dom/client';
import { createGlobalStyle } from 'styled-components';
import { Jupyter, JupyterLabApp, JupyterLabPluginsCore } from '@datalayer/jupyter-react';
import { JupyterLab } from '@jupyterlab/application';
import * as collaborationExtension from '@jupyter/collaboration-extension';
import * as datalayerExtension from './jupyterlab/index';
import Datalayer from './Datalayer';

const { extensionsPromises, mimeExtensionsPromises } = JupyterLabPluginsCore;

const onReady = (jupyterLab: JupyterLab) => {
console.log('JupyterLab is ready.')
/*
jupyterLab.deactivatePlugin(datalayerExtension.PLUGIN_ID).then((deactivatedDownstreamPlugins) => {
console.log('Deeactivated downstream plugins', deactivatedDownstreamPlugins);
});
jupyterLab.deregisterPlugin(datalayerExtension.PLUGIN_ID, true);
*/
const ThemeGlobalStyle = createGlobalStyle<any>`
body {
background-color: white !important;
}
`

const DatalayerDev = () => {
const [jupyterLab, setJupyterLab] = useState<JupyterLab>();
const onReady = (jupyterLab: JupyterLab) => {
/*
jupyterLab.deactivatePlugin(datalayerExtension.PLUGIN_ID).then((deactivatedDownstreamPlugins) => {
console.log('Deeactivated downstream plugins', deactivatedDownstreamPlugins);
});
jupyterLab.deregisterPlugin(datalayerExtension.PLUGIN_ID, true);
*/
setJupyterLab(jupyterLab);
}
return (
<>
{jupyterLab && <Datalayer app={jupyterLab}/>}
<JupyterLabApp
extensions={[
datalayerExtension,
collaborationExtension,
]}
extensionPromises={extensionsPromises}
mimeExtensionsPromises={mimeExtensionsPromises}
position="absolute"
hostId="jupyterlab-app-id"
height="100vh"
headless={true}
onReady={onReady}
/>
</>
)
}
const DatalayerDev = () => (
<JupyterLabApp
extensions={[
datalayerExtension,
collaborationExtension,
]}
extensionPromises={extensionsPromises}
mimeExtensionsPromises={mimeExtensionsPromises}
position="absolute"
hostId="jupyterlab-app-id"
height="100vh"
onReady={onReady}
/>
)

const div = document.createElement('div');
document.body.appendChild(div);
const root = createRoot(div);

root.render(
<Jupyter startDefaultKernel={false} disableCssLoading={true}>
<ThemeGlobalStyle />
<DatalayerDev/>
</Jupyter>
);
8 changes: 4 additions & 4 deletions src/tabs/JupyterLabTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const JupyterLabTab = (props: JupyterFrontEndProps) => {
<Box sx={{display: 'flex'}}>
<Box>
<NavList sx={{
'> *': {
paddingTop: '0px'
}
}}>
'> *': {
paddingTop: '0px'
}
}}>
<NavList.Item aria-current={nav === 1 ? 'page' : undefined} onClick={e => setNav(1)}>
<NavList.LeadingVisual>
<NetworkIcon />
Expand Down

0 comments on commit eb99ce8

Please sign in to comment.