Skip to content

Commit

Permalink
Merge pull request #5 from jburel/binder
Browse files Browse the repository at this point in the history
Binder
  • Loading branch information
jburel committed May 26, 2020
2 parents c4d87fc + 3d2788c commit c48f396
Show file tree
Hide file tree
Showing 26 changed files with 5,122 additions and 5 deletions.
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
# This is a template useful to create guides
# User guide for Fiji and OMERO
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ome/omero-guide-fiji/master?filepath=notebooks)


This guide demonstrates how to analyze data stored in OMERO in Fiji.
This can be done using the User Interface or via the scripting facility in Fiji.


To run the notebooks, you can either [run on mybinder.org](https://mybinder.org/v2/gh/ome/omero-guide-fiji/master?filepath=notebooks) or build locally with [repo2docker](https://repo2docker.readthedocs.io/).

To build locally:

* Install [Docker](https://www.docker.com/) if required
* Create a virtual environment and install repo2docker from PyPI.
* Clone this repository
* Run ``repo2docker``.
* Depending on the permissions, you might have to run the command as an admin

```
pip install jupyter-repo2docker
git clone https://github.com/ome/omero-guide-fiji.git
cd omero-guide-fiji
repo2docker .
```

This a Sphinx based documentation.
If you are unfamiliar with Sphinx, we recommend that you first read
[Getting Started with Sphinx](https://docs.readthedocs.io/en/stable/intro/getting-started-with-sphinx.html).

When creating a new repository, this template could be used.

The value in ``conf.py`` should be replaced by the name of your project.
15 changes: 15 additions & 0 deletions binder/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bsdtar
curl
dbus-x11
firefox
less
net-tools
openjdk-8-jre
unzip
vim
xfce4
xfce4-panel
xfce4-session
xfce4-settings
xorg
xubuntu-icon-theme
13 changes: 13 additions & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: base
channels:
- conda-forge
- ome
- manics
dependencies:
- beakerx
- pip
- websockify=0.9.0
- pip:
# Recent jupyter-server-proxy to load vnc_lite.html instead of /
# https://github.com/jupyterhub/jupyter-server-proxy/pull/151
- https://github.com/jupyterhub/jupyter-server-proxy/archive/0e67e1afd0bab1342443f13bd147a2f8c682e9e0.zip
63 changes: 63 additions & 0 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
set -eux

env

VNC_APPLICATION_DIR=$CONDA_DIR/vnc
mkdir $VNC_APPLICATION_DIR
pushd $VNC_APPLICATION_DIR

# Novnc: just want web files
curl -sSfL https://github.com/novnc/noVNC/archive/v1.1.0.tar.gz | tar -zxf -

# Patch novnc to use correct path to websockify (defaults to /)
# Note if you use vnc.html you will need to patch ui.js to use the correct path
# and also to override localstorage which may store an incorrect path from a
# different session
# Also resize server instead of scaling client
sed -i.bak \
-e "s%\('path', 'websockify'\)%'path', window.location.pathname.replace(/[^/]*$/, '').substring(1) + 'websockify'); console.log('websockify path:' + path%" \
-re "s%rfb.scaleViewport = .+%rfb.resizeSession = readQueryVariable('resize', true);%" \
noVNC-1.1.0/vnc_lite.html

# Install tigervnc
curl -sSfL 'https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz' | tar -zxf - --strip=2


cp $REPO_DIR/jupyter_desktop/share/xstartup .
chmod +x xstartup


# Desktop applications
# Fiji and OMERO insight

OMERO_INSIGHT_VERSION=5.5.11
OMERO_INSIGHT_URL_BASE=https://github.com/ome/omero-insight/releases/download/v$OMERO_INSIGHT_VERSION

wget https://downloads.imagej.net/fiji/latest/fiji-nojre.zip
unzip -q fiji-nojre.zip
rm fiji-nojre.zip


pushd Fiji.app/plugins
wget -q $OMERO_INSIGHT_URL_BASE/omero_ij-$OMERO_INSIGHT_VERSION-all.jar
popd

mkdir Desktop

# Copy the script to the Desktop
cp -R $REPO_DIR/scripts Desktop

cp $REPO_DIR/jupyter_desktop/share/*.desktop Desktop
chmod +x Desktop/*.desktop

popd

pushd $REPO_DIR/jupyter_desktop

# Configure jupyter-server-proxy VNC
# https://jupyter-server-proxy.readthedocs.io/en/latest/server-process.html#specifying-config-from-python-packages
pip install .
python -c "from pkg_resources import iter_entry_points; print(list(iter_entry_points(group='jupyter_serverproxy_servers')))"

popd
7 changes: 7 additions & 0 deletions binder/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -eux

export DISPLAY=:1.0
ln -s "$CONDA_DIR/vnc/Desktop"

exec "$@"
26 changes: 26 additions & 0 deletions jupyter_desktop/jupyter_desktop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os


def setup_desktop():
VNC_APPLICATION_DIR = os.path.join(os.getenv('CONDA_DIR'), 'vnc')
return {
'command': [
'websockify', '-v',
'--web', VNC_APPLICATION_DIR + '/noVNC-1.1.0',
'--heartbeat', '30',
'5901',
'--unix-target', VNC_APPLICATION_DIR + '/socket',
'--',
VNC_APPLICATION_DIR + '/bin/vncserver',
'-verbose',
'-xstartup', VNC_APPLICATION_DIR + '/xstartup',
'-geometry', '1024x768',
'-SecurityTypes', 'None',
'-rfbunixpath', VNC_APPLICATION_DIR + '/socket',
'-fg',
':1',
],
'port': 5901,
'timeout': 30,
'mappath': {'/': '/vnc_lite.html'},
}
17 changes: 17 additions & 0 deletions jupyter_desktop/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import setuptools


setuptools.setup(
name="jupyter-desktop-server",
# py_modules rather than packages, since we only have 1 file
py_modules=['jupyter_desktop'],
entry_points={
'jupyter_serverproxy_servers': [
'desktop = jupyter_desktop:setup_desktop',
]
},
install_requires=['jupyter-server-proxy'],
package_data={
'jupyter_desktop': ['desktop/*'],
},
)
14 changes: 14 additions & 0 deletions jupyter_desktop/share/Fiji.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Desktop Entry]
Version=1.0
Name=Fiji Is Just ImageJ
GenericName=Fiji Is Just ImageJ
X-GNOME-FullName=Fiji Is Just ImageJ
Comment=Scientific Image Analysis
Type=Application
Categories=Education;Science;ImageProcessing;
Exec=/srv/conda/vnc/Fiji.app/ImageJ-linux64
TryExec=/srv/conda/vnc/Fiji.app/ImageJ-linux64
Terminal=false
StartupNotify=true
Icon=/srv/conda/vnc/Fiji.app/images/icon.png
StartupWMClass=fiji-Main
2 changes: 2 additions & 0 deletions jupyter_desktop/share/xstartup
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /usr/bin/dbus-launch xfce4-session

0 comments on commit c48f396

Please sign in to comment.