Skip to content

Commit 20c7015

Browse files
committed
initial commit
1 parent 02e3d74 commit 20c7015

File tree

16 files changed

+475
-2
lines changed

16 files changed

+475
-2
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: build
5+
on:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: [3.6, 3.7, 3.8, 3.9]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install flake8 pytest
29+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30+
- name: Lint with flake8
31+
run: |
32+
# stop the build if there are Python syntax errors or undefined names
33+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
34+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
35+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
36+
- name: Test with pytest
37+
run: |
38+
pytest

.gitignore

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

CHANGELOG.md

Whitespace-only changes.

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2023, Jens Henrik Goebbert
3+
Copyright (c) 2020, Forschungszentrum Juelich GmbH, Juelich Supercomputing Centre
4+
All rights reserved.
45

56
Redistribution and use in source and binary forms, with or without
67
modification, are permitted provided that the following conditions are met:

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
graft jupyter_nestdesktop_proxy/icons
2+
graft jupyter_nestdesktop_proxy/bin

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
1+
![build](https://github.com/FZJ-JSC/jupyter-nestdesktop/workflows/build/badge.svg)
2+
13
# jupyter-nestdesktop-proxy
2-
Jupyter extensions for running a NEST Desktop proxy
4+
Integrate NEST Desktop in your Jupyter environment for an fast, feature-rich and easy to use remote desktop in the browser.
5+
6+
## Requirements
7+
- Python 3.6+
8+
- Jupyter Notebook 6.0+
9+
- JupyterLab >= 3.x
10+
- jupyter-server-proxy >= 3.1.0
11+
12+
This package executes the `nest-desktop` command. This command assumes the `nest-desktop` command is available in the environment's $PATH.
13+
14+
## Security
15+
Be aware, [NEST Desktop](https://nest-desktop.readthedocs.io) does not encrypt the communication and/or requires password to connect.
16+
17+
### NEST Desktop
18+
[NEST Desktop](https://nest-desktop.readthedocs.io) is a web-based GUI application for NEST Simulator, an advanced simulation tool for the computational neuroscience.
19+
20+
### Jupyter-Server-Proxy
21+
[Jupyter-Server-Proxy](https://jupyter-server-proxy.readthedocs.io) lets you run arbitrary external processes (such as Xpra-HTML5) alongside your notebook, and provide authenticated web access to them.
22+
23+
## Install
24+
25+
#### Create and Activate Environment
26+
```
27+
virtualenv -p python3 venv
28+
source venv/bin/activate
29+
```
30+
31+
#### Install jupyter-nestdesktop-proxy
32+
```
33+
pip install git+https://github.com/FZJ-JSC/jupyter-nestdesktop-proxy.git
34+
```
35+
36+
#### Enable jupyter-nestdesktop-proxy Extensions
37+
For Jupyter Classic, activate the jupyter-server-proxy extension:
38+
```
39+
jupyter serverextension enable --sys-prefix jupyter_server_proxy
40+
```
41+
42+
For Jupyter Lab, install the @jupyterlab/server-proxy extension:
43+
```
44+
jupyter labextension install @jupyterlab/server-proxy
45+
jupyter lab build
46+
```
47+
48+
#### Start Jupyter Classic or Jupyter Lab
49+
Click on the NEST Desktop icon from the JupyterLab Launcher or the NEST Desktop item from the New dropdown in Jupyter Classic.
50+
Connect to your database as instructed in the Quickstart section.
51+
52+
## Configuration
53+
This package calls `nest-desktop` with settings. Please read the [NEST Desktop](https://nest-desktop.readthedocs.io/en/latest/user/index.html) if you want to know the details.
54+
You have to modify `setup_nestdesktop()` in `jupyter_nestdesktop_proxy/__init__.py` for change.
55+
56+
## Credits
57+
- NEST Desktop
58+
- jupyter-server-proxy
59+
60+
## License
61+
BSD 3-Clause

conftest.py

Whitespace-only changes.

environment.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# run: conda env create --file environment.yml
2+
name: jupyter-nestdesktop-proxy
3+
channels:
4+
- conda-forge
5+
dependencies:
6+
- jupyterlab=3
7+
- jupyterlab_server
8+
- jupyter-server-proxy>=3.1.0
9+
- jupyter_conda
10+
- pip
11+
- pip:
12+
# - nest-desktop>=3.2.0
13+
- -r file:requirements.txt
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import os
2+
import logging
3+
4+
logger = logging.getLogger(__name__)
5+
logger.setLevel('INFO')
6+
7+
HERE = os.path.dirname(os.path.abspath(__file__))
8+
9+
10+
def get_nestdesktop_executable(prog):
11+
from shutil import which
12+
13+
# Find prog in known locations
14+
other_paths = [
15+
os.path.join('/opt/nestdesktop/bin', prog),
16+
]
17+
18+
wp = os.path.join(HERE, 'bin', prog)
19+
if os.path.exists(wp):
20+
return wp
21+
22+
if which(prog):
23+
return prog
24+
25+
for op in other_paths:
26+
if os.path.exists(op):
27+
return op
28+
29+
if os.getenv("NESTDESKTOP_BIN") is not None:
30+
return os.getenv("NESTDESKTOP_BIN")
31+
32+
raise FileNotFoundError(f'Could not find {prog} in PATH')
33+
34+
35+
def _nestdesktop_mappath(path):
36+
37+
# always pass the url parameter
38+
if path in ('/', '/index.html', ):
39+
path = '/index.html'
40+
41+
return path
42+
43+
44+
def setup_nestdesktop():
45+
""" Setup commands and and return a dictionary compatible
46+
with jupyter-server-proxy.
47+
"""
48+
49+
# launchers url file including url parameters
50+
path_info = 'nestdesktop/index.html' + _nestdesktop_urlparams()
51+
52+
# create command
53+
cmd = [
54+
get_nestdesktop_executable('nest-desktop'),
55+
'-h localhost',
56+
'-p {port}',
57+
]
58+
logger.info('NEST Desktop command: ' + ' '.join(cmd))
59+
60+
return {
61+
'command': cmd,
62+
'mappath': _nestdesktop_mappath,
63+
'absolute_url': False,
64+
'timeout': 90,
65+
'new_browser_tab': True,
66+
'launcher_entry': {
67+
'enabled': True,
68+
'icon_path': os.path.join(HERE, 'icons/nestdesktop-logo.svg'),
69+
'title': 'NEST Desktop',
70+
'path_info': path_info,
71+
},
72+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# you might need to modify your environment
4+
# before you can start 'nest-desktop'
5+
# Do it here.
6+
7+
# example:
8+
# module purge
9+
# module load Stages/2023
10+
# module load GCCcore/.11.3.0
11+
# module load nest-desktop/3.2.0
12+
13+
nest-desktop "$@"

0 commit comments

Comments
 (0)