Skip to content

Commit 4aae6ba

Browse files
authored
Merge pull request #46 from ModelDriven/ST6RI-84
ST6RI-84 Jupyter notebook integration
2 parents ebe6624 + 0edf311 commit 4aae6ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+21987
-19050
lines changed

isysml/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.gradle
2+
.idea
3+
.ipynb_checkpoints
4+
*.ipynb
5+
build

isysml/README.md

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# ISysML
2+
3+
A [Jupyter](http://jupyter.org/) kernel for executing SysML v2 models. The kernel executes models via the new SysML textual language. Some of the additional commands should be supported as needed via a syntax similar to the IPython magics.
4+
5+
Built on top of [jupyter-jvm-basekernel](https://github.com/SpencerPark/jupyter-jvm-basekernel).
6+
7+
### Requirements
8+
9+
1. [Java >= 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html). Java 11 is the latest LTS release and should be considered if selecting a version, but if a Java 8, 9, 10, or 12 build is installed everything _should_ still be working fine.
10+
11+
2. Some Jupyter-like environment to use the kernel in.
12+
13+
A non-exhaustive list of options:
14+
15+
* [Jupyter](http://jupyter.org/install)
16+
* [JupyterLab](http://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html)
17+
* [nteract](https://nteract.io/desktop)
18+
19+
### Installing
20+
21+
After meeting the [requirements](#requirements), the kernel can be installed locally. Any time you wish to remove a kernel you may use `jupyter kernelspec remove sysml`. If you have installed the kernel to multiple directories, this command may need to be run multiple times as it might only remove 1 installation at a time.
22+
23+
24+
#### (Coming Soon) Install pre-built binary
25+
26+
Get the latest _release_ of the software with no compilation needed. See [Install from source](#install-from-source) for building the latest commit.
27+
28+
**Note:** if you have an old installation or a debug one from running `gradlew installKernel` it is suggested that it is first removed via `jupyter kernelspec remove sysml`.
29+
30+
1. Download the release from the [releases tab](.). A prepackaged distribution will be in an artifact named `isysml-$version.zip`.
31+
32+
2. Unzip it into a temporary location. It should have at least the `install.py` and `sysml` folder extracted in there.
33+
34+
3. Run the installer with the same python command used to install jupyter. The installer is a python script and has the same options as `jupyter kernelspec install` but additionally supports configuring some of the kernel properties mentioned further below in the README.
35+
36+
```bash
37+
# Pass the -h option to see the help page
38+
> python3 install.py -h
39+
40+
# Otherwise a common install command is
41+
> python3 install.py --sys-prefix
42+
```
43+
44+
4. Check that it installed with `jupyter kernelspec list` which should contain `sysml`.
45+
46+
#### Install from source
47+
48+
Get the latest version of the kernel but possibly run into some issues with installing. This is also the route to take if you wish to contribute to the kernel.
49+
50+
On *nix `chmod u+x gradlew && ./gradlew installKernel`
51+
52+
On Windows `gradlew installKernel`
53+
54+
See all available options for configuring the install path with `gradlew -q help --task installKernel`. Pass the `--default`, `--user`, `--sys-prefix`, `--prefix`, `--path`, or `--legacy` options to change the install location. Also use the `--param` flag (repeatedly) to set (or add) parameter values with the parameter names (not environment variable) specified in the configuration section below. For example `--param classpath:/my/classpath/root` to append to the classpath list.
55+
56+
### Configuring
57+
58+
Configuring the kernel can be done via environment variables. These can be set on the system or inside the `kernel.json`. The configuration can be done at install time, which may be repeated as often as desired. The parameters are listed with `python3 install.py -h` as well as below in the list of options. Configuration done via the installer (or `gradlew installKernel --param ...:...`) should use the names in the _Parameter name_ column.
59+
60+
#### List of options
61+
62+
| Environment variable | Parameter name | Default | Description |
63+
|----------------------|----------------|---------|-------------|
64+
| `ISYSML_LIBRARY_PATH` | `library-path` | `""` | A file path separator delimited list of library path entries that should be available to the user code. **Important:** no matter what OS, this should use forward slash "/" as the file separator.
65+
66+
#### Changing VM options
67+
68+
The kernel VM parameters must currently be assigned in the `kernel.json` by adding/editing a JSON dictionary at the `env` key and changing the `argv` list. To find where the kernel is installed run
69+
70+
```bash
71+
> jupyter kernelspec list
72+
Available kernels:
73+
sysml .../kernels/sysml
74+
python3 .../kernels/python3
75+
```
76+
77+
and the `kernel.json` file will be in the given directory.
78+
79+
For example to set the heap size to `128m`:
80+
81+
```diff
82+
{
83+
- "argv": [ "java", "-jar", "{connection_file}"],
84+
+ "argv": [ "java", "-Xmx128m", "-jar", "{connection_file}"],
85+
"display_name": "SysML",
86+
"language": "sysml",
87+
"interrupt_mode": "message",
88+
"env": {
89+
}
90+
}
91+
```
92+
93+
### Run
94+
95+
This is where the documentation diverges as each environment has its own way of selecting a kernel. To test from command line with Jupyter's console application run:
96+
97+
```bash
98+
jupyter console --kernel=sysml
99+
```
100+
101+
Then at the prompt try:
102+
```
103+
In [1]: package test{}
104+
```

isysml/build.gradle

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
plugins {
2+
id 'java'
3+
id 'io.github.spencerpark.jupyter-kernel-installer' version '2.1.0'
4+
id "com.github.johnrengelman.shadow" version "4.0.4"
5+
}
6+
7+
group 'org.omg.sysml.jupyter.kernel'
8+
version '1.0-SNAPSHOT'
9+
10+
sourceCompatibility = 1.8
11+
12+
wrapper {
13+
gradleVersion = '4.10.3'
14+
distributionType = Wrapper.DistributionType.ALL
15+
}
16+
17+
repositories {
18+
mavenCentral()
19+
}
20+
21+
dependencies {
22+
compile group: 'io.github.spencerpark', name: 'jupyter-jvm-basekernel', version: '2.3.0'
23+
compile fileTree(dir: 'lib', include: '*.jar')
24+
}
25+
26+
jupyter {
27+
kernelName = 'sysml'
28+
kernelDisplayName = 'SysML'
29+
kernelLanguage = 'sysml'
30+
kernelInterruptMode = 'message'
31+
kernelExecutable = shadowJar.archivePath
32+
kernelResources = files('src/main/resources/kernel')
33+
34+
kernelParameters {
35+
list('library-path', 'ISYSML_LIBRARY_PATH') {
36+
separator = PATH_SEPARATOR
37+
description = '''A file path separator delimited list of library path entries that should be available to the user code. **Important:** no matter what OS, this should use forward slash "/" as the file separator.'''
38+
}
39+
}
40+
}
41+
42+
jar {
43+
manifest {
44+
attributes 'Main-Class': 'org.omg.sysml.jupyter.kernel.ISysML'
45+
}
46+
}
47+
48+
artifacts {
49+
archives shadowJar
50+
}
51+
52+
zipKernel.dependsOn shadowJar
53+
installKernel.dependsOn shadowJar
54+
55+
installKernel {
56+
kernelInstallPath = commandLineSpecifiedPath(userInstallPath)
57+
}
54.9 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)