Skip to content
Snippets Groups Projects
Commit 8dd6e5e0 authored by Reiner Jung's avatar Reiner Jung
Browse files

Updated language setup.

parent 11216d2c
Branches
Tags
No related merge requests found
#Base image
FROM jupyter/datascience-notebook@sha256:73a577b006b496e1a1c02f5be432f4aab969c456881c4789e0df77c89a0a60c2
USER root
#RUN conda install -n root conda=4.6
#RUN conda update jupyterlab
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-11-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
RUN conda install --quiet --yes --freeze-installed \
'python-language-server' \
'r-languageserver' \
&& python3 -m pip install --no-cache-dir --no-deps \
'jupyter_lsp==0.7' \
&& jupyter labextension install --no-build \
'@krassowski/jupyterlab-lsp@0.7.1' \
&& jupyter lab build --dev-build=False --minimize=True \
&& conda clean --all -f -y \
&& rm -rf \
$CONDA_DIR/share/jupyter/lab/staging \
/home/$NB_USER/.cache/yarn \
&& fix-permissions $CONDA_DIR \
&& fix-permissions /home/$NB_USER
# Add Language server File
ADD org.oceandsl.configuration.ide-1.0.0-SNAPSHOT-ls.jar /etc/
ADD jupyter_notebook_config.py /etc/jupyter
# Add kernel
ADD cp-dsl-jupyter-kernel /cp-dsl-jupyter-kernel/
COPY kernel.json /opt/conda/share/jupyter/kernels/xtext/kernel.json
COPY logback.xml /opt/conda/share/jupyter/kernels/xtext/logback.xml
# CP-DSL Jupyter Setup
The CP-DSL Jupyter setup allows to run Jupyter with an LSP extension for the
Configuration and Parameterization DSL (CP-DSL) with its associated kernel
for code generation.
In the following, we explain how to setup the docker image and then run the
whole kaboodle.
## Setup
This git repository does not come with the necessary binary artifacts for
the CP-DSL LSP component and the kernel. They must be obtained from cp-dsl and
jupyter-base-kernel repository.
### Download and compile the CP-DSL
The following instructions reflect actions on a command line interface.
Leave the `cp-dsl-jupyter-setup` directory and clone the CP-DSL repository
alongside it.
`git clone https://git.se.informatik.uni-kiel.de/oceandsl/cp-dsl.git`
Switch into the `cp-dsl` directory
`cd cp-dsl`
and build the DSL with
`mvn -P build -Dinstallation=false compile`
`mvn -P build -Dinstallation=false package`
This produces various jar files. Copy `org.oceandsl.configuration.ide-1.0.0-SNAPSHOT-ls.jar`
to the `cp-dsl-juypter-setup directory`
`cp bundles/org.oceandsl.configuration.ide/target/org.oceandsl.configuration.ide-1.0.0-SNAPSHOT-ls.jar ../cp-dsl-jupyter-setup`
### Download and compile the CP-DSL Kernel
The following instructions reflect actions on a command line interface.
Leave the `cp-dsl` directory and clone the CP-DSL Jupyter kernel repository
alongside the `cp-dsl-jupyter-setup`.
`git clone https://git.se.informatik.uni-kiel.de/oceandsl/cp-dsl-jupyter-kernel.git`
Switch to the `cp-dsl-jupyter-kernel` directory.
`cd cp-dsl-jupyter-kernel`
and copy the necessary files from `cp-dsl` to the `libs` directory
`cp ../cp-dsl/bundles/org.oceandsl.configuration.model.support.uvic/target/org.oceandsl.configuration.model.support.uvic-1.0.0-SNAPSHOT.jar libs`
`cp ../cp-dsl/bundles/org.oceandsl.configuration.model.support.mitgcm/target/org.oceandsl.configuration.model.support.mitgcm-1.0.0-SNAPSHOT.jar libs`
`cp ../cp-dsl/bundles/org.oceandsl.configuration/target/org.oceandsl.configuration-1.0.0-SNAPSHOT.jar libs`
Now build the kernel with
`./gradlew build`
After the build is complete, switch back to `cp-dsl-jupyter-setup` with
`cd ../cp-dsl-jupyter-setup`
and unpack the build distribution package of the kernel inside the `cp-dsl-jupyter-setup`
`unzip ../cp-dsl-jupyter-kernel/build/distributions/cp-dsl-jupyter-kernel.zip`
### Check setup script
Check `kernel.json`, `jupyter_notebook_config.py` and `Dockerfile` that the appropriate
files have been named there.
The `kernel.json` file
```
{"argv":["/cp-dsl-jupyter-kernel/bin/cp-dsl-juypter-kernel","{connection_file}"],
"display_name":"oconf",
"language": "oconf"
}
```
The `jupyter_notebook_config.py` must contain `org.oceandsl.configuration.ide-1.0.0-SNAPSHOT-ls.jar`
as file under `c.LanguageServerManager.language_servers`.
## How to run
Start ```run.sh``` This works on Linux, but not on windows.
On Windows simply run *docker build -t lsp* and *docker-compose up* after that.
Jupyter lab can be reached on localhost:18888/lab using a token provided in windows shell.
version: '2'
services:
lsp-lab:
build: .
ports:
- '18888:8888'
- '18888:8888'
environment:
- GRANT_SUDO:"yes"
user: jovyan
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from jupyter_core.paths import jupyter_data_dir
import subprocess
import os
import errno
import stat
# jupyter_notebook_config.py
import shutil
c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
# https://github.com/jupyter/notebook/issues/3130
c.FileContentsManager.delete_to_trash = False
# Generate a self-signed certificate
if 'GEN_CERT' in os.environ:
dir_name = jupyter_data_dir()
pem_file = os.path.join(dir_name, 'notebook.pem')
try:
os.makedirs(dir_name)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(dir_name):
pass
else:
raise
# Generate a certificate if one doesn't exist on disk
subprocess.check_call(['openssl', 'req', '-new',
'-newkey', 'rsa:2048',
'-days', '365',
'-nodes', '-x509',
'-subj', '/C=XX/ST=XX/L=XX/O=generated/CN=generated',
'-keyout', pem_file,
'-out', pem_file])
# Restrict access to the file
os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR)
c.NotebookApp.certfile = pem_file
# c is a magic, lazy variable
c.LanguageServerManager.language_servers = {
"a-language-server-implementation": {
# if installed as a binary
"version": 1,
"argv": ["java","-jar", "/etc/org.oceandsl.configuration.ide-1.0.0-SNAPSHOT-ls.jar"],
"languages": ["oconf"]
}
}
{"argv":["/cp-dsl-jupyter-kernel/bin/cp-dsl-jupyter-kernel","{connection_file}"],
"display_name":"oconf",
"language": "oconf"
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="HOME_LOG" value="/home/jovyan/work/xtext.log"/>
<appender name="FILE-ROLLING" class="ch.qos.logback.core.FileAppender">
<file>${HOME_LOG}</file>
<encoder>
<pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="FILE-ROLLING"/>
</root>
</configuration>
run.sh 0 → 100755
#!/bin/bash
docker build -t lsp .
docker run -v $PWD/work:/home/jovyan/work lsp
# end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment