Skip to content

Commit 03a446a

Browse files
committed
fetch pyodide after setup and handle absence gracefully
1 parent f029085 commit 03a446a

File tree

3 files changed

+12
-39
lines changed

3 files changed

+12
-39
lines changed

build.gradle.kts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ val testDurations = mutableListOf<TestDuration>()
237237

238238
tasks {
239239
withType<Test> {
240-
minHeapSize = "1g"
241-
maxHeapSize = "6g"
240+
minHeapSize = "32g"
241+
maxHeapSize = "120g"
242242
useJUnitPlatform()
243243
testLogging {
244244
events = setOf(
@@ -276,17 +276,6 @@ tasks {
276276
// libraryProducers = listOf("ai.hypergraph.kaliningraph.notebook.Integration")
277277
// }
278278

279-
listOf(
280-
"Rewriter", "PrefAttach",
281-
"rewriting.CipherSolver",
282-
"RegexDemo", "smt.TestSMT"
283-
).forEach { fileName ->
284-
register(fileName, org.gradle.api.tasks.JavaExec::class) {
285-
mainClass = "ai.hypergraph.kaliningraph.${fileName}Kt"
286-
classpath += objects.fileCollection().from(configurations.named("jvmTestCompileClasspath"))
287-
}
288-
}
289-
290279
/*
291280
* To deploy to Maven Local and start the notebook, run:
292281
*

src/jvmTest/kotlin/ai/hypergraph/kaliningraph/repair/ProbabilisticLBH.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,10 @@ class ProbabilisticLBH {
742742
/*
743743
./gradlew jvmTest --tests "ai.hypergraph.kaliningraph.repair.ProbabilisticLBH.testSLPs"
744744
*/
745-
// @Test
745+
@Test
746746
fun testSLPs() {
747747
// val pt = k2.startPTree(List(35) { "_" })!!
748-
val pt = completeWithSparseGRE(List(35) { "_" }, k2)!!
748+
val pt = completeWithSparseGRE(List(20) { "_" }, k3)!!
749749
pt.sampleStrWithoutReplacement().take(1000)//.filter { it.length <= 80 }
750750
.forEach { println("\\texttt{ " + it.replace("{", "\\{")
751751
.replace("}", "\\}") + "}\\\\") }

src/jvmTest/kotlin/ai/hypergraph/kaliningraph/repair/RepairServer.kt

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,18 @@ class RepairServer {
1515

1616
fun handleRequest(template: String, cfg: String): String {
1717
val cfgHash = cfg.hashCode()
18-
val cfg = if (cfgHash in map) map[cfgHash] else {
19-
cfg.trimIndent().lines().map { it.split(" -> ").let { Pair(it[0], it[1].split(" ")) } }
20-
.toSet().freeze()
21-
}!!
18+
val cfg = if (cfgHash in map) map[cfgHash]!!
19+
else cfg.trimIndent().lines().map { it.split(" -> ").let { it[0] to it[1].split(" ") } }.toSet().freeze()
2220

2321
val tks = template.tokenizeByWhitespace()
24-
return (if (tks.any { it == "_" })
25-
cfg.startPTree(tks)?.sampleStrWithoutReplacement()
26-
else
27-
initiateSerialRepair(tks,cfg)
28-
)?.take(1000000)?.joinToString("\n")?: "null"
22+
return (if (tks.any { it == "_" }) cfg.startPTree(tks)?.sampleStrWithoutReplacement()
23+
else initiateSerialRepair(tks, cfg))?.take(1000000)?.joinToString("\n")?: "null"
2924
}
3025

3126
/*
3227
./gradlew jvmTest --tests "ai.hypergraph.kaliningraph.repair.RepairServer.testRepairServer"
3328
*/
34-
// @Test
29+
@Test
3530
fun testRepairServer() {
3631
val server = HttpServer.create(InetSocketAddress("127.0.0.1", 8088), 0)
3732

@@ -53,7 +48,7 @@ class RepairServer {
5348
val s2 = decodeB64ToUtf8(params["s2_b64"])
5449

5550
// Log first 10 code points of each (emoji-safe)
56-
println("RepairServer: s1[0..10]='${firstTen(s1)}' | s2[0..10]='${firstTen(s2)}'")
51+
println("RepairServer: s1[0..10]='${s1.take(10)}' | s2[0..10]='${s2.take(10)}'")
5752

5853
// Respond with concatenation of the *decoded* strings
5954
val resp = handleRequest(s1, s2)
@@ -87,24 +82,13 @@ class RepairServer {
8782
if (s.isEmpty()) emptyMap() else buildMap {
8883
s.split("&").forEach { kv ->
8984
val i = kv.indexOf('=')
90-
if (i >= 0) put(urlDecode(kv.substring(0, i)), urlDecode(kv.substring(i + 1)))
85+
if (i >= 0) put(urlDecode(kv.take(i)), urlDecode(kv.substring(i + 1)))
9186
else if (kv.isNotEmpty()) put(urlDecode(kv), "")
9287
}
9388
}
9489

9590
private fun urlDecode(x: String) = URLDecoder.decode(x, StandardCharsets.UTF_8)
9691

9792
private fun decodeB64ToUtf8(b64: String?): String =
98-
try {
99-
if (b64.isNullOrEmpty()) ""
100-
else String(Base64.getDecoder().decode(b64), StandardCharsets.UTF_8)
101-
} catch (_: IllegalArgumentException) {
102-
"" // invalid Base64 -> treat as empty
103-
}
104-
105-
private fun firstTen(s: String): String {
106-
val want = min(10, s.codePointCount(0, s.length))
107-
val endIdx = s.offsetByCodePoints(0, want)
108-
return s.take(endIdx)
109-
}
93+
if (b64.isNullOrEmpty()) "" else String(Base64.getDecoder().decode(b64), StandardCharsets.UTF_8)
11094
}

0 commit comments

Comments
 (0)