Skip to content

Commit 303341b

Browse files
kz930claude
andcommitted
test(verify): keep the model fixture's script and target off the command line
Windows rebuilds argv from one command line and drops the quotes inside an argument, so the multiline -c script and the a"b\c_species target both reached Python broken. The script now goes in a file and the target in an environment variable. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8d9cc74 commit 303341b

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -996,19 +996,28 @@ private object FittedModelFixture {
996996
columns,
997997
scored.getOrElse(rows)
998998
)
999-
val fit =
1000-
s"""import base64, pickle, sys
999+
// The script goes in a file and the target in the environment: Windows
1000+
// rebuilds argv from one command line, dropping the quotes inside an argument.
1001+
val fit = Files.writeString(
1002+
dir.resolve("fit.py"),
1003+
s"""import base64, os, pickle, sys
10011004
|import pandas as pd
10021005
|from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
1006+
|target = os.environ["FIXTURE_TARGET"]
10031007
|table = pd.read_json(sys.argv[1], lines=True).iloc[:-1]
1004-
|X = table.drop(sys.argv[2], axis=1).select_dtypes("number")
1008+
|X = table.drop(target, axis=1).select_dtypes("number")
10051009
|for estimator in [${estimators.mkString(", ")}]:
1006-
| fitted = estimator.fit(X, table[sys.argv[2]])
1010+
| fitted = estimator.fit(X, table[target])
10071011
| print(base64.b64encode(b"pickle " + pickle.dumps(fitted)).decode("ascii"))
10081012
|""".stripMargin
1013+
)
10091014
val out = new java.io.ByteArrayOutputStream()
10101015
val exit = scala.sys.process
1011-
.Process(Seq(PyOpExecHarness.resolvePython(), "-c", fit, fitData.toString, target))
1016+
.Process(
1017+
Seq(PyOpExecHarness.resolvePython(), fit.toString, fitData.toString),
1018+
None,
1019+
"FIXTURE_TARGET" -> target
1020+
)
10121021
.#>(out)
10131022
.!
10141023
require(exit == 0, s"fitting the fixture's ${estimators.mkString(", ")} exited with $exit")

0 commit comments

Comments
 (0)