Skip to content

Commit 551793c

Browse files
authored
Simplify examples (#84)
Remove progress-printing from examples in order to simplify them. Also add tasks to run all examples so that #83 doesn't happen again.
1 parent a4ac1ac commit 551793c

File tree

4 files changed

+74
-226
lines changed

4 files changed

+74
-226
lines changed

examples/build.gradle.kts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
val exampleTestTasks = ArrayList<TaskProvider<*>>()
2+
3+
exampleTestTasks += tasks.register<Exec>("runExampleScript") {
4+
group = "Application"
5+
description = "Runs the 'example-script.main.kts' script"
6+
commandLine("kotlinc", "-script", file("example-script.main.kts"))
7+
}
8+
9+
exampleTestTasks += tasks.register<GradleBuild>("runExampleProject") {
10+
group = "Verification"
11+
description = "Runs examples/example-project as a standalone build"
12+
dir = file("example-project")
13+
tasks = listOf("run")
14+
}
15+
16+
val notebooks = fileTree(file("example-notebooks")) {
17+
exclude(".ipynb_checkpoints")
18+
}
19+
20+
exampleTestTasks += notebooks.map { notebook ->
21+
val buildDir = project.layout.buildDirectory.asFile.get()
22+
tasks.register<Exec>("run${notebook.nameWithoutExtension}Notebook") {
23+
group = "Application"
24+
description = "Runs the '${notebook.name}' notebook with 'jupyter nbconvert --execute'"
25+
commandLine(
26+
"jupyter", "nbconvert",
27+
"--execute",
28+
"--to", "ipynb",
29+
"--output-dir=$buildDir",
30+
notebook,
31+
)
32+
}
33+
}
34+
35+
tasks.register("runExamples") {
36+
group = "Application"
37+
description = "Runs everything in 'examples' directory"
38+
dependsOn(exampleTestTasks)
39+
}

0 commit comments

Comments
 (0)