This is an automated email from the ASF dual-hosted git repository. weichenxu123 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 6a89f654bb54 [SPARK-52130][FOLLOW-UP][ML][CONNECT] Refine error message when model.summary is evicted 6a89f654bb54 is described below commit 6a89f654bb54de73f20f07c10ca6f7ff186bbeb6 Author: Weichen Xu <weichen...@databricks.com> AuthorDate: Fri May 30 12:51:47 2025 +0800 [SPARK-52130][FOLLOW-UP][ML][CONNECT] Refine error message when model.summary is evicted ### What changes were proposed in this pull request? Refine error message when model.summary is evicted. In Spark Connect ML handler, `model.summary.XXX` invocation has different code path than `model.evaluate`, and it should raise readable error message when model.summary is evicted, otherwise the MLHandler will raise NullPointerException which is not friendly to end-users. ### Why are the changes needed? Refine error message. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Manually. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #51048 from WeichenXu123/improve-scml-summary-error. Authored-by: Weichen Xu <weichen...@databricks.com> Signed-off-by: Weichen Xu <weichen...@databricks.com> --- .../org/apache/spark/sql/connect/ml/MLHandler.scala | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLHandler.scala b/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLHandler.scala index 927f959f714b..d40b70ba0813 100644 --- a/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLHandler.scala +++ b/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/ml/MLHandler.scala @@ -28,7 +28,7 @@ import org.apache.spark.ml.{Estimator, EstimatorUtils, Model, Transformer} import org.apache.spark.ml.evaluation.Evaluator import org.apache.spark.ml.param.{ParamMap, Params} import org.apache.spark.ml.tree.TreeConfig -import org.apache.spark.ml.util.{MLWritable, Summary} +import org.apache.spark.ml.util.{HasTrainingSummary, MLWritable, Summary} import org.apache.spark.sql.DataFrame import org.apache.spark.sql.connect.common.LiteralValueProtoConverter import org.apache.spark.sql.connect.ml.Serializer.deserializeMethodArguments @@ -223,10 +223,17 @@ private[connect] object MLHandler extends Logging { .build() case proto.MlCommand.CommandCase.FETCH => - val helper = AttributeHelper( - sessionHolder, - mlCommand.getFetch.getObjRef.getId, - mlCommand.getFetch.getMethodsList.asScala.toArray) + val objRefId = mlCommand.getFetch.getObjRef.getId + val methods = mlCommand.getFetch.getMethodsList.asScala.toArray + val obj = sessionHolder.mlCache.get(objRefId) + if (obj != null && obj.isInstanceOf[HasTrainingSummary[_]] + && methods(0).getMethod == "summary" + && !obj.asInstanceOf[HasTrainingSummary[_]].hasSummary) { + throw MLCacheInvalidException( + objRefId, + sessionHolder.mlCache.getOffloadingTimeoutMinute) + } + val helper = AttributeHelper(sessionHolder, objRefId, methods) val attrResult = helper.getAttribute attrResult match { case s: Summary => --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org