Skip to content

Commit 20a1050

Browse files
committed
update notebook support
1 parent 99e390e commit 20a1050

16 files changed

+523
-977
lines changed

README.md

+18-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repositories {
2020
}
2121

2222
dependencies {
23-
implementation("com.github.breandan:kaliningraph:0.1.4")
23+
implementation("com.github.breandan:kaliningraph:0.1.5")
2424
}
2525
```
2626

@@ -38,7 +38,7 @@ dependencies {
3838
<dependency>
3939
<groupId>com.github.breandan</groupId>
4040
<artifactId>kaliningraph</artifactId>
41-
<version>0.1.4</version>
41+
<version>0.1.5</version>
4242
</dependency>
4343
</project>
4444
```
@@ -48,10 +48,13 @@ dependencies {
4848
To access notebook support, use the following line magic:
4949

5050
```
51-
%use @https://raw.githubusercontent.com/breandan/kaliningraph/master/kaliningraph.json
51+
@file:DependsOn("com.github.breandan:kaliningraph:0.1.5")
5252
```
5353

54-
For more information, explore the [tutorial](notebooks/Hello%20Kaliningraph.ipynb).
54+
For more information, explore our tutorials:
55+
56+
* [Hello Kaliningraph.ipynb](notebooks/Hello%20Kaliningraph.ipynb).
57+
* [Program Graphs.ipynb](notebooks/Program%20Graphs.ipynb).
5558

5659
## Graphs, Inductively
5760

@@ -70,22 +73,22 @@ Run [the demo](src/main/kotlin/edu/mcgill/kaliningraph/HelloKaliningraph.kt) via
7073
To construct a graph, the [graph builder DSL](src/main/kotlin/edu/mcgill/kaliningraph/LabeledGraph.kt) provides an small alphabet:
7174

7275
```kotlin
73-
val graph = Graph { a - b - c - d - e; a - c - e }
76+
val graph = LGBuilder { a - b - c - d - e; a - c - e }
7477
```
7578

7679
This is the same as:
7780

7881
```kotlin
79-
val abcde = Graph { a - b - c - d - e }
80-
val ace = Graph { a - c - e }
82+
val abcde = LGBuilder { a - b - c - d - e }
83+
val ace = LGBuilder { a - c - e }
8184
val graph = abcde + ace
8285
```
8386

8487
Equality is supported using the [Weisfeiler-Lehman](http://www.jmlr.org/papers/volume12/shervashidze11a/shervashidze11a.pdf#page=6) test:
8588

8689
```kotlin
87-
val x = Graph { a - b - c - d - e; a - c - e }
88-
val y = Graph { b - c - d - e - f; b - d - f }
90+
val x = LGBuilder { a - b - c - d - e; a - c - e }
91+
val y = LGBuilder { b - c - d - e - f; b - d - f }
8992
assertEquals(x == y) // true
9093
```
9194

@@ -98,12 +101,12 @@ Kaliningraph supports a number of graph visualizations.
98101
Graph visualization is made possible thanks to [KraphViz](https://github.com/nidi3/graphviz-java#kotlin-dsl).
99102

100103
```kotlin
101-
val de = Graph { d - e }
102-
val dacbe = Graph { d - a - c - b - e }
103-
val dce = Graph { d - c - e }
104+
val de = LGBuilder { d - e }
105+
val dacbe = LGBuilder { d - a - c - b - e }
106+
val dce = LGBuilder { d - c - e }
104107

105-
val abcd = Graph { a - b - c - d }
106-
val cfde = Graph { c - "a" - f - d - e }
108+
val abcd = LGBuilder { a - b - c - d }
109+
val cfde = LGBuilder { c - "a" - f - d - e }
107110

108111
val dg = Graph(dacbe, dce, de) + Graph(abcd, cfde)
109112
dg.show()
@@ -145,7 +148,7 @@ The above snippet should display something like the following:
145148
Bidirectional translation to various graph formats, including [Graphviz](https://github.com/nidi3/graphviz-java), [JGraphT](https://jgrapht.org/guide/UserOverview), [Tinkerpop](https://tinkerpop.apache.org/docs/current/reference/) and [RedisGraph](https://oss.redislabs.com/redisgraph/) is supported:
146149

147150
```kotlin
148-
val g = Graph { a - b - c - a }
151+
val g = LGBuilder { a - b - c - a }
149152
.toJGraphT().toKaliningraph()
150153
.toTinkerpop().toKaliningraph()
151154
.toGraphviz().toKaliningraph()

build.gradle.kts

+24-37
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,62 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
44

55
plugins {
66
`maven-publish`
7-
kotlin("jvm") version "1.5.0-M1"
7+
kotlin("jvm") version "1.4.30"
88
kotlin("jupyter.api") version "0.8.3.255"
9-
id("com.github.ben-manes.versions") version "0.36.0"
9+
id("com.github.ben-manes.versions") version "0.38.0"
1010
}
1111

1212
group = "com.github.breandan"
13-
version = "0.1.4"
13+
version = "0.1.5"
1414

1515
repositories {
1616
mavenCentral()
1717
maven("https://jitpack.io")
1818
maven("https://clojars.org/repo")
19+
// TODO: Remove pending https://github.com/sosy-lab/java-smt/issues/201#issuecomment-777336656
1920
maven("http://logicrunch.research.it.uu.se/maven/") {
2021
isAllowInsecureProtocol = true
2122
}
2223
}
2324

2425
dependencies {
25-
implementation(kotlin("stdlib-jdk8"))
26+
implementation(kotlin("stdlib"))
27+
2628
val ejmlVersion = "0.40"
2729
api("org.ejml:ejml-kotlin:$ejmlVersion")
2830
api("org.ejml:ejml-all:$ejmlVersion")
29-
api("guru.nidi:graphviz-kotlin:0.18.0")
31+
api("guru.nidi:graphviz-kotlin:0.18.1")
3032

31-
val commonsRngVersion = "1.3"
32-
implementation("org.apache.commons:commons-rng-sampling:$commonsRngVersion")
33-
implementation("org.apache.commons:commons-rng-simple:$commonsRngVersion")
3433
implementation("org.slf4j:slf4j-simple:1.7.30")
3534

3635
testImplementation("com.github.breandan:tensor:master-SNAPSHOT")
3736

38-
val multik_version = "0.0.1"
39-
testImplementation("org.jetbrains.kotlinx:multik-api:$multik_version")
40-
testImplementation("org.jetbrains.kotlinx:multik-default:$multik_version")
37+
val multikVersion = "0.0.1"
38+
testImplementation("org.jetbrains.kotlinx:multik-api:$multikVersion")
39+
testImplementation("org.jetbrains.kotlinx:multik-default:$multikVersion")
4140

4241
testImplementation("org.jetbrains.kotlin:kotlin-scripting-jsr223")
4342
testImplementation("com.github.kwebio:kweb-core:0.7.33")
44-
testImplementation("org.sosy-lab:java-smt:3.7.0")
43+
testImplementation("org.sosy-lab:java-smt:3.7.0") // {
44+
// exclude(group = "uuverifiers", module = "princess_2.13")
45+
// }
4546
testImplementation("org.sosy-lab:javasmt-solver-mathsat5:5.6.5")
4647

4748
// http://www.ti.inf.uni-due.de/fileadmin/public/tools/grez/grez-manual.pdf
4849
// implementation(files("$projectDir/libs/grez.jar"))
4950

5051
// http://www.informatik.uni-bremen.de/agbkb/lehre/rbs/seminar/AGG-ShortManual.pdf
51-
testImplementation(files("$projectDir/libs/aggEngine_V21_classes.jar"))
52+
// testImplementation(files("$projectDir/libs/aggEngine_V21_classes.jar"))
5253

5354
// https://github.com/jgralab/jgralab/wiki
54-
testImplementation("de.uni-koblenz.ist:jgralab:8.1.0")
55+
// testImplementation("de.uni-koblenz.ist:jgralab:8.1.0")
5556

5657
testImplementation("junit", "junit", "4.13.2")
5758
testImplementation("com.github.ajalt.clikt:clikt:3.1.0")
5859
testImplementation("com.redislabs:jredisgraph:2.3.0")
5960
testImplementation("io.lacuna:bifurcan:0.2.0-alpha4")
6061
testImplementation("org.junit.jupiter:junit-jupiter:5.7.0")
62+
6163
val jgraphtVersion by extra { "1.5.0" }
6264
testImplementation("org.jgrapht:jgrapht-core:$jgraphtVersion")
6365
testImplementation("org.jgrapht:jgrapht-opt:$jgraphtVersion")
@@ -81,13 +83,6 @@ tasks {
8183
}
8284
}
8385

84-
listOf("KotlinJupyter").forEach { fileName ->
85-
register(fileName, JavaExec::class) {
86-
main = "edu.mcgill.kaliningraph.notebook.${fileName}Kt"
87-
classpath = sourceSets["main"].runtimeClasspath
88-
}
89-
}
90-
9186
listOf("HelloKaliningraph", "Rewriter",
9287
"PrefAttach", "rewriting.CipherSolver").forEach { fileName ->
9388
register(fileName, JavaExec::class) {
@@ -108,26 +103,18 @@ tasks {
108103
testLogging { events("passed", "skipped", "failed") }
109104
}
110105

111-
val installPathLocal = "${System.getProperty("user.home")}/.jupyter_kotlin/libraries"
106+
/*
107+
If overwriting an older version, it is necessary to first run:
112108
113-
val genNotebookJSON by creating(JavaExec::class) {
114-
main = "edu.mcgill.kaliningraph.codegen.NotebookGenKt"
115-
classpath = sourceSets["main"].runtimeClasspath
116-
args = listOf(projectDir.path, project.version.toString())
117-
}
109+
rm -rf ~/.m2/repository/com/github/breandan/kaliningraph \
110+
~/.ivy2/cache/com.github.breandan/kaliningraph
118111
119-
val jupyterInstall by registering(Copy::class) {
120-
dependsOn(genNotebookJSON)
121-
dependsOn("publishToMavenLocal")
122-
val installPath = findProperty("ath") ?: installPathLocal
123-
doFirst { mkdir(installPath) }
124-
from(file("kaliningraph.json"))
125-
into(installPath)
126-
doLast { logger.info("Kaliningraph notebook support was installed in: $installPath") }
127-
}
112+
To deploy to Maven Local and start the notebook, run:
113+
114+
./gradlew [build publishToMavenLocal] jupyterRun -x test
115+
*/
128116

129117
val jupyterRun by creating(Exec::class) {
130-
dependsOn(jupyterInstall)
131118
commandLine("jupyter", "notebook", "--notebook-dir=notebooks")
132119
}
133120

kaliningraph.json

-22
This file was deleted.

0 commit comments

Comments
 (0)