Skip to content

Commit b581ae0

Browse files
kz930claude
andcommitted
test(verify): pickle the harness spec's model from a script file
Windows drops the quotes from a multiline `-c` argument, so the bytes literal reached Python as `bpickle` and the fixture failed before the harness ran. Write the script to a temporary .py file and run that. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 135b9be commit b581ae0

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/PyOpExecHarnessSpec.scala‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,20 @@ class PyOpExecHarnessSpec extends AnyFlatSpec with Matchers {
239239
}
240240

241241
// A fitted DecisionTreeClassifier behind the marker the cast writes, pickled
242-
// by the interpreter the harness runs so the two share a sklearn.
242+
// by the interpreter the harness runs so the two share a sklearn. The script
243+
// goes through a file because Windows drops the quotes from a `-c` argument.
243244
private def fittedTreeCell(): Array[Byte] = {
244-
val script =
245+
val script = Files.createTempFile("py-op-harness-model-", ".py")
246+
script.toFile.deleteOnExit()
247+
Files.writeString(
248+
script,
245249
"""import base64, pickle, sys
246250
|from sklearn.tree import DecisionTreeClassifier
247251
|model = DecisionTreeClassifier(random_state=0).fit([[0.0], [1.0]], [0, 1])
248252
|sys.stdout.write(base64.b64encode(b"pickle " + pickle.dumps(model)).decode("ascii"))
249253
|""".stripMargin
250-
val encoded = Process(Seq(PyOpExecHarness.resolvePython(), "-c", script)).!!
254+
)
255+
val encoded = Process(Seq(PyOpExecHarness.resolvePython(), script.toString)).!!
251256
Base64.getDecoder.decode(encoded.trim)
252257
}
253258

0 commit comments

Comments
 (0)