Skip to content

[SPARK-59202][ML][TESTS] Enable save/load round-trip tests in Java ML tree suites - #58492

Open
uros-b wants to merge 1 commit into
apache:masterfrom
uros-b:enable-java-ml-saveload-tests
Open

[SPARK-59202][ML][TESTS] Enable save/load round-trip tests in Java ML tree suites#58492
uros-b wants to merge 1 commit into
apache:masterfrom
uros-b:enable-java-ml-saveload-tests

Conversation

@uros-b

@uros-b uros-b commented Sep 3, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Six Java ML tree test suites -- JavaDecisionTreeClassifierSuite, JavaGBTClassifierSuite, JavaRandomForestClassifierSuite, JavaDecisionTreeRegressorSuite, JavaGBTRegressorSuite, JavaRandomForestRegressorSuite -- carried commented-out save/load round-trip tests with a // TODO: Add test once save/load are implemented. SPARK-6725 marker.

Save/load has long shipped (MLWritable / MLReadable). This enables those tests. The commented code was obsolete -- it used the old save(SparkContext, path) / load(SparkContext, path) mllib API and referenced stale variable names (model2 / model3) -- so each block is rewritten to the current API:

File tempDir = Utils.createTempDir(System.getProperty("java.io.tmpdir"), "spark");
String path = new File(tempDir, "model").getPath();
try {
  model.save(path);
  <Model> sameModel = <Model>.load(path);
  TreeTests.checkEqual(model, sameModel);
} finally {
  Utils.deleteRecursively(tempDir);
}

Why are the changes needed?

The blocks were dead (obsolete API and wrong variable names) rather than merely disabled. Enabling them adds Java-facing save/load round-trip coverage for the tree models, matching what the Scala suites already provide via DefaultReadWriteTest.

Does this PR introduce any user-facing change?

No. Test-only.

How was this patch tested?

Ran the six enabled Java suites locally; all pass.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.8)

@uros-b

uros-b commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

Thank you @tdcmeehan! Adding @HyukjinKwon & @zhengruifeng for ML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants