Skip to content
Snippets Groups Projects
Commit 10b17010 authored by Alice Grosch's avatar Alice Grosch
Browse files
parents b8390864 e6772aa0
No related branches found
No related tags found
No related merge requests found
Showing
with 497 additions and 0 deletions
FROM jupyter/minimal-notebook
USER root
RUN mkdir /software
WORKDIR /software
RUN wget 'https://www.paraview.org/files/v5.7/ParaView-5.7.0-osmesa-MPI-Linux-Python3.7-64bit.tar.gz' \
&& tar xf ParaView-5.7.0-osmesa-MPI-Linux-Python3.7-64bit.tar.gz \
&& rm ParaView-5.7.0-osmesa-MPI-Linux-Python3.7-64bit.tar.gz
ENV PATH="/software/ParaView-5.7.0-osmesa-MPI-Linux-Python3.7-64bit/bin:${PATH}"
RUN apt-get update && apt-get -y install openssh-server net-tools \
&& rm -rf /var/lib/apt/lists/*
USER $NB_UID
WORKDIR /home/$NB_USER/work
COPY --chown=1000:100 pvlink /home/$NB_USER/.jupyter/pvlink
COPY --chown=1000:100 pv_server.py /home/$NB_USER/work/
COPY --chown=1000:100 remoterenderer_test.ipynb /home/$NB_USER/work/
RUN pip install service_identity \
voila \
ipyvuetify voila-vuetify \
/home/$NB_USER/.jupyter/pvlink \
&& jupyter labextension install --no-build \
@jupyter-widgets/jupyterlab-manager \
@jupyter-voila/jupyterlab-preview \
jupyter-vuetify \
/home/$NB_USER/.jupyter/pvlink/js \
&& jupyter lab build && jupyter lab clean \
&& npm cache clean --force \
&& rm -rf $CONDA_DIR/share/jupyter/lab/staging \
&& rm -rf /home/$NB_USER/.cache/yarn \
&& rm -rf /home/$NB_USER/.node-gyp
\ No newline at end of file
# add paraview modules
import sys
sys.path.append('/home/grosch/Devel/install/ParaView-v5.6.0/build/lib/python3.6/site-packages/')
# import to process args
import os
# import paraview modules.
from paraview.web import pv_wslink
from paraview.web import protocols as pv_protocols
from paraview import simple
from wslink import server
try:
import argparse
except ImportError:
# since Python 2.6 and earlier don't have argparse, we simply provide
# the source for the same as _argparse and we use it instead.
from vtk.util import _argparse as argparse
# =============================================================================
# Create custom PVServerProtocol class to handle clients requests
# =============================================================================
class _DemoServer(pv_wslink.PVServerProtocol):
authKey = "wslink-secret"
def initialize(self):
# Bring used components
self.registerVtkWebProtocol(pv_protocols.ParaViewWebMouseHandler())
self.registerVtkWebProtocol(pv_protocols.ParaViewWebViewPort())
self.registerVtkWebProtocol(pv_protocols.ParaViewWebViewPortImageDelivery())
self.updateSecret(_DemoServer.authKey)
# Disable interactor-based render calls
simple.GetRenderView().EnableRenderOnInteraction = 0
simple.GetRenderView().Background = [0,0,0]
cone = simple.Cone()
simple.Show(cone)
simple.Render()
# Update interaction mode
pxm = simple.servermanager.ProxyManager()
interactionProxy = pxm.GetProxy('settings', 'RenderViewInteractionSettings')
interactionProxy.Camera3DManipulators = ['Rotate', 'Pan', 'Zoom', 'Pan', 'Roll', 'Pan', 'Zoom', 'Rotate', 'Zoom']
# =============================================================================
# Main: Parse args and start server
# =============================================================================
if __name__ == "__main__":
# Create argument parser
parser = argparse.ArgumentParser(description="ParaViewWeb Demo")
# Add default arguments
server.add_arguments(parser)
# Extract arguments
args = parser.parse_args()
# Start server
server.start_webserver(options=args, protocol=_DemoServer)
\ No newline at end of file
recursive-include pvlink/static *.*
include pvlink.json
pvlink
===============================
Displays the ParaviewWeb RemoteRenderer in a Jupyter Notebook
Installation
------------
To install use pip:
$ pip install pvlink
$ jupyter nbextension enable --py --sys-prefix pvlink
To install for jupyterlab
$ jupyter labextension install pvlink
For a development installation (requires npm),
$ git clone https://github.com//pvlink.git
$ cd pvlink
$ pip install -e .
$ jupyter nbextension install --py --symlink --sys-prefix pvlink
$ jupyter nbextension enable --py --sys-prefix pvlink
$ jupyter labextension install js
When actively developing your extension, build Jupyter Lab with the command:
$ jupyter lab --watch
This take a minute or so to get started, but then allows you to hot-reload your javascript extension.
To see a change, save your javascript, watch the terminal for an update.
Note on first `jupyter lab --watch`, you may need to touch a file to get Jupyter Lab to open.
- To release a new version of pvlink on PyPI:
Update _version.py (set release version, remove 'dev')
git add the _version.py file and git commit
`python setup.py sdist upload`
`python setup.py bdist_wheel upload`
`git tag -a X.X.X -m 'comment'`
Update _version.py (add 'dev' and increment minor)
git add and git commit
git push
git push --tags
- To release a new version of pvlink on NPM:
```
# clean out the `dist` and `node_modules` directories
git clean -fdx
npm install
npm publish
```
\ No newline at end of file
Displays the ParaviewWeb RemoteRenderer in a Jupyter Notebook
Package Install
---------------
**Prerequisites**
- [node](http://nodejs.org/)
```bash
npm install --save pvlink
```
// Entry point for the unpkg bundle containing custom model definitions.
//
// It differs from the notebook bundle in that it does not need to define a
// dynamic baseURL for the static assets and may load some css that would
// already be loaded by the notebook otherwise.
// Export widget models and views, and the npm package version number.
module.exports = require('./remoterenderer.js');
module.exports['version'] = require('../package.json').version;
// This file contains the javascript that is run when the notebook is loaded.
// It contains some requirejs configuration and the `load_ipython_extension`
// which is required for any notebook extension.
//
// Some static assets may be required by the custom widget javascript. The base
// url for the notebook is not known at build time and is therefore computed
// dynamically.
__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/pvlink';
// Configure requirejs
if (window.require) {
window.require.config({
map: {
"*" : {
"pvlink": "nbextensions/pvlink/index",
}
}
});
}
// Export the required load_ipython_extension
module.exports = {
load_ipython_extension: function() {}
};
// Export widget models and views, and the npm package version number.
module.exports = require('./remoterenderer.js');
module.exports['version'] = require('../package.json').version;
var plugin = require('./index');
var base = require('@jupyter-widgets/base');
module.exports = {
id: 'pvlink',
requires: [base.IJupyterWidgetRegistry],
activate: function(app, widgets) {
widgets.registerWidget({
name: 'pvlink',
version: plugin.version,
exports: plugin
});
},
autoStart: true
};
var widgets = require('@jupyter-widgets/base');
var _ = require('lodash');
import ParaViewWebClient from 'paraviewweb/src/IO/WebSocket/ParaViewWebClient';
import RemoteRenderer from 'paraviewweb/src/NativeUI/Canvas/RemoteRenderer';
import SizeHelper from "paraviewweb/src/Common/Misc/SizeHelper";
import SmartConnect from 'wslink/src/SmartConnect';
export var RemoteRendererModel = widgets.DOMWidgetModel.extend({
defaults: _.extend(widgets.DOMWidgetModel.prototype.defaults(), {
_model_name: 'RemoteRendererModel',
_view_name: 'RemoteRendererView',
_model_module: 'pvlink',
_view_module: 'pvlink',
_model_module_version: '0.1.0',
_view_module_version: '0.1.0',
})
});
export var RemoteRendererView = widgets.DOMWidgetView.extend({
render: function () {
var that = this;
// div to hold the canvas of the RemoteRenderer.
var render_div = document.createElement('div');
render_div.style.height = '100%';
render_div.style.width = '100%';
this.el.appendChild(render_div);
/* Get configuration for SmartConnect.
* SmartConnect will establish a direct
* WebSocket connection using Autobahn.
*/
var config = {
sessionURL: this.model.get('sessionURL'),
secret: this.model.get('authKey')
};
var smartConnect = SmartConnect.newInstance({ config: config });
smartConnect.onConnectionReady(function (connection) {
// Create the RemoteRenderer
var pvwClient = ParaViewWebClient.createClient(connection, [
'MouseHandler',
'ViewPort',
'ViewPortImageDelivery']
);
var renderer = new RemoteRenderer(pvwClient);
renderer.setContainer(render_div);
renderer.setView(that.model.get('viewID'));
renderer.onImageReady(function () {
// Resize when the renderer is placed within a widget.
if (that.el.style.width != '100%') {
that.el.style.width = '100%';
renderer.resize();
}
console.log("We are good.");
});
// Handle size changes when the entire window is resized.
SizeHelper.onSizeChange(function () {
renderer.resize();
});
SizeHelper.startListening();
// Explicit render called from python side.
that.model.on('change:_update', function () {
renderer.render(true);
}, that);
});
smartConnect.connect();
},
});
{
"name": "pvlink",
"version": "0.1.0",
"description": "Displays the ParaviewWeb RemoteRenderer in a Jupyter Notebook",
"author": "Alice Grosch",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com//pvlink.git"
},
"keywords": [
"jupyter",
"widgets",
"ipython",
"ipywidgets",
"jupyterlab-extension"
],
"files": [
"lib/**/*.js",
"dist/*.js"
],
"scripts": {
"clean": "rimraf dist/",
"prepublish": "webpack",
"build": "webpack",
"watch": "webpack --watch --mode=development",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"webpack": "^3.5.5",
"rimraf": "^2.6.1"
},
"dependencies": {
"@jupyter-widgets/base": "^1.1 || ^2",
"lodash": "^4.17.4",
"hammerjs": "^2.0.8",
"monologue.js": "^0.3.5",
"paraviewweb": "^3.2.12",
"wslink": "^0.1.12"
},
"jupyterlab": {
"extension": "lib/labplugin"
}
}
var path = require('path');
var version = require('./package.json').version;
// Custom webpack rules are generally the same for all webpack bundles, hence
// stored in a separate local variable.
var rules = [
{ test: /\.css$/, use: ['style-loader', 'css-loader']}
]
module.exports = [
{// Notebook extension
//
// This bundle only contains the part of the JavaScript that is run on
// load of the notebook. This section generally only performs
// some configuration for requirejs, and provides the legacy
// "load_ipython_extension" function which is required for any notebook
// extension.
//
entry: './lib/extension.js',
output: {
filename: 'extension.js',
path: path.resolve(__dirname, '..', 'pvlink', 'static'),
libraryTarget: 'amd'
}
},
{// Bundle for the notebook containing the custom widget views and models
//
// This bundle contains the implementation for the custom widget views and
// custom widget.
// It must be an amd module
//
entry: './lib/index.js',
output: {
filename: 'index.js',
path: path.resolve(__dirname, '..', 'pvlink', 'static'),
libraryTarget: 'amd'
},
devtool: 'source-map',
module: {
rules: rules
},
externals: ['@jupyter-widgets/base']
},
{// Embeddable pvlink bundle
//
// This bundle is generally almost identical to the notebook bundle
// containing the custom widget views and models.
//
// The only difference is in the configuration of the webpack public path
// for the static assets.
//
// It will be automatically distributed by unpkg to work with the static
// widget embedder.
//
// The target bundle is always `dist/index.js`, which is the path required
// by the custom widget embedder.
//
entry: './lib/embed.js',
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: 'amd',
publicPath: 'https://unpkg.com/pvlink@' + version + '/dist/'
},
devtool: 'source-map',
module: {
rules: rules
},
externals: ['@jupyter-widgets/base']
}
];
{
"load_extensions": {
"pvlink/extension": true
}
}
recursive-include pvlink/static *.*
include pvlink.json
pvlink
===============================
Displays the ParaviewWeb RemoteRenderer in a Jupyter Notebook
Installation
------------
To install use pip:
$ pip install pvlink
$ jupyter nbextension enable --py --sys-prefix pvlink
To install for jupyterlab
$ jupyter labextension install pvlink
For a development installation (requires npm),
$ git clone https://github.com//pvlink.git
$ cd pvlink
$ pip install -e .
$ jupyter nbextension install --py --symlink --sys-prefix pvlink
$ jupyter nbextension enable --py --sys-prefix pvlink
$ jupyter labextension install js
When actively developing your extension, build Jupyter Lab with the command:
$ jupyter lab --watch
This take a minute or so to get started, but then allows you to hot-reload your javascript extension.
To see a change, save your javascript, watch the terminal for an update.
Note on first `jupyter lab --watch`, you may need to touch a file to get Jupyter Lab to open.
- To release a new version of pvlink on PyPI:
Update _version.py (set release version, remove 'dev')
git add the _version.py file and git commit
`python setup.py sdist upload`
`python setup.py bdist_wheel upload`
`git tag -a X.X.X -m 'comment'`
Update _version.py (add 'dev' and increment minor)
git add and git commit
git push
git push --tags
- To release a new version of pvlink on NPM:
```
# clean out the `dist` and `node_modules` directories
git clean -fdx
npm install
npm publish
```
\ No newline at end of file
from ._version import version_info, __version__
from .remoterenderer import *
def _jupyter_nbextension_paths():
return [{
'section': 'notebook',
'src': 'static',
'dest': 'pvlink',
'require': 'pvlink/extension'
}]
version_info = (0, 1, 0, 'alpha', 0)
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
__version__ = '%s.%s.%s%s'%(version_info[0], version_info[1], version_info[2],
'' if version_info[3]=='final' else _specifier_[version_info[3]]+str(version_info[4]))
Displays the ParaviewWeb RemoteRenderer in a Jupyter Notebook
Package Install
---------------
**Prerequisites**
- [node](http://nodejs.org/)
```bash
npm install --save pvlink
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment