Skip to content

Commit

Permalink
Top level script (jupyter-server#180)
Browse files Browse the repository at this point in the history
* use start.sh

* bump version

* fix script target

* clean up docker and status extension

* remove extra comment
  • Loading branch information
Steve Silvester authored and GitHub Enterprise committed Sep 22, 2021
1 parent 95f4622 commit 387990a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
/.git
.gitattributes
.gitignore
.ipynb_checkpoints
.pytest_cache
.virtual_documents
Untitled.*
checkouts
LICENSE
node_modules
Dockerfile
coverage
data_studio_jupyter_extensions.egg-info
__pycache__
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ RUN pip install -q -r requirements.txt
# Install local extension package
RUN mkdir extensions
COPY . ./extensions
RUN which pip
RUN which python
RUN pip install -U ./extensions
RUN cat extensions/data_studio_jupyter_extensions/_version.py
RUN python -c "import data_studio_jupyter_extensions; print(data_studio_jupyter_extensions.__version__)"
RUN cd extensions && ./deployment/bin/version_check.sh

#######################
# Prepare runtime image
Expand Down Expand Up @@ -83,8 +80,7 @@ COPY --chown=${NB_USER}:${NB_USER} deployment/config/condarc ${APP_DIR}/.condarc
COPY --chown=${NB_USER}:${NB_USER} deployment/config/npmrc ${APP_DIR}/.npmrc
COPY --chown=${NB_USER}:${NB_USER} version ${APP_DIR}
COPY --chown=${NB_USER}:${NB_USER} deployment ${APP_DIR}
RUN python -c "import data_studio_jupyter_extensions; print(data_studio_jupyter_extensions.__version__)"
RUN cat ${APP_DIR}/version
RUN ${APP_DIR}/bin/version_check.sh

USER ${NB_USER}
WORKDIR ${APP_DIR}
Expand Down
11 changes: 11 additions & 0 deletions deployment/bin/version_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
version=$(cat version)
echo "docker version: ${version}"
cd ~
py_version=$(python -c "import data_studio_jupyter_extensions; print(data_studio_jupyter_extensions.__version__)")
echo "python version: ${py_version}"

if [ $version != ${py_version} ]; then
echo "Version mismatch!"
exit 1
fi
15 changes: 3 additions & 12 deletions src/status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ import theme from '@tidbits/react-tidbits/theme';

import { ReactWidget } from '@jupyterlab/apputils';

// TODO: thread config through PageConfig instead of detecting env
// once the functionality is available in JupyterServer
declare var process: {
env: {
NODE_ENV: string;
};
};

// Define the error states
// https://github.pie.apple.com/pie-data-studio/notebook-service/blob/761d63604966db5918d2e491c0f89cce454b7f67/app/com/apple/datastudio/model/ResourceState.scala#L20
const ERROR_STATES = [
Expand Down Expand Up @@ -95,11 +87,10 @@ export const kernelStatusPlugin: JupyterFrontEndPlugin<void> = {
console.log('JupyterLab extension "Kernel Status" is activated!');

const pathCache = new LRUCache(50);
let url = URLExt.join(PageConfig.getWsUrl(), 'subscribe');
let url =
PageConfig.getOption('studioSubscribeURL') ||
URLExt.join(PageConfig.getWsUrl(), 'subscribe');

if (process.env.NODE_ENV == 'test') {
url = 'ws://localhost:5555';
}
const ws = new WebSocket(url);

const getPath = (kernel_id: string) => {
Expand Down
6 changes: 4 additions & 2 deletions test/status.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import WS from 'jest-websocket-mock';
import { kernelStatusPlugin } from '../src/status';

import * as testUtils from './utils';
import { PageConfig } from '@jupyterlab/coreutils';

const server = new JupyterServer();
const defaultRendermime = NBTestUtils.defaultRenderMime();
Expand Down Expand Up @@ -59,8 +60,9 @@ describe('status', () => {
rendermime: defaultRendermime
});
app.docRegistry.addWidgetFactory(factory);

const server = new WS('ws://localhost:5555', { jsonProtocol: true });
const url = 'ws://localhost:5555';
PageConfig.setOption('studioSubscribeURL', url);
const server = new WS(url, { jsonProtocol: true });
await kernelStatusPlugin.activate(app, loggerRegistry, notebookTracker);

// Use the factory to create a panel and simulate the widget
Expand Down

0 comments on commit 387990a

Please sign in to comment.