This is an automated email from the ASF dual-hosted git repository.
Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new fecd39328250 CAMEL-24526: camel-djl - reject the zoo tabular
applications instead of returning no-op predictors
fecd39328250 is described below
commit fecd393282503c4517273fcef04c884ece485630
Author: Andrea Cosentino <[email protected]>
AuthorDate: Thu Aug 27 19:02:22 2026 +0200
CAMEL-24526: camel-djl - reject the zoo tabular applications instead of
returning no-op predictors
The zoo linear/softmax regression predictors were empty "// TODO: impl"
stubs
whose process() did nothing, so a djl:tabular/linear_regression or
tabular/softmax_regression route silently returned the input body unchanged
as
if it were the prediction (a silent wrong result). The DJL model zoo
publishes no
tabular regression models, and the input/output types of a tabular model are
specific to the user's data, so no generic zoo predictor can exist for these
applications. getZooPredictor now throws a clear RuntimeCamelException for
the
tabular applications, pointing users to the supported custom
model+translator
path, and the two no-op stub classes are removed.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../djl/model/ModelPredictorProducer.java | 15 +++++-----
.../tabular/ZooLinearRegressionPredictor.java | 32 ----------------------
.../tabular/ZooSoftmaxRegressionPredictor.java | 32 ----------------------
.../djl/model/ModelPredictorProducerTest.java | 20 ++++++++++++--
4 files changed, 25 insertions(+), 74 deletions(-)
diff --git
a/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/ModelPredictorProducer.java
b/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/ModelPredictorProducer.java
index 0e61056b8d83..29b0c289b146 100644
---
a/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/ModelPredictorProducer.java
+++
b/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/ModelPredictorProducer.java
@@ -55,8 +55,6 @@ import
org.apache.camel.component.djl.model.nlp.ZooTextEmbeddingPredictor;
import org.apache.camel.component.djl.model.nlp.ZooTextGenerationPredictor;
import
org.apache.camel.component.djl.model.nlp.ZooTokenClassificationPredictor;
import org.apache.camel.component.djl.model.tabular.CustomTabularPredictor;
-import
org.apache.camel.component.djl.model.tabular.ZooLinearRegressionPredictor;
-import
org.apache.camel.component.djl.model.tabular.ZooSoftmaxRegressionPredictor;
import
org.apache.camel.component.djl.model.timeseries.CustomForecastingPredictor;
import org.apache.camel.component.djl.model.timeseries.ZooForecastingPredictor;
@@ -135,11 +133,14 @@ public final class ModelPredictorProducer {
return new ZooTextEmbeddingPredictor(endpoint);
}
- // Tabular
- if (LINEAR_REGRESSION.getPath().equals(applicationPath)) {
- return new ZooLinearRegressionPredictor(endpoint);
- } else if (SOFTMAX_REGRESSION.getPath().equals(applicationPath)) {
- return new ZooSoftmaxRegressionPredictor(endpoint);
+ // Tabular: the DJL model zoo does not publish tabular regression
models, and the input and
+ // output types of a tabular model are specific to the user's data, so
there is no generic zoo
+ // predictor for these applications. Users must supply their own model
and translator and use
+ // the custom variant (see getCustomPredictor /
CustomTabularPredictor) instead.
+ if (LINEAR_REGRESSION.getPath().equals(applicationPath) ||
SOFTMAX_REGRESSION.getPath().equals(applicationPath)) {
+ throw new RuntimeCamelException(
+ "Zoo models are not available for tabular application: " +
applicationPath
+ + ". Provide your own model and
translator and use the custom predictor instead.");
}
// Audio
diff --git
a/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/tabular/ZooLinearRegressionPredictor.java
b/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/tabular/ZooLinearRegressionPredictor.java
deleted file mode 100644
index 43961f8a28bf..000000000000
---
a/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/tabular/ZooLinearRegressionPredictor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.djl.model.tabular;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.djl.DJLEndpoint;
-import org.apache.camel.component.djl.model.AbstractPredictor;
-
-public class ZooLinearRegressionPredictor extends AbstractPredictor {
- public ZooLinearRegressionPredictor(DJLEndpoint endpoint) {
- super(endpoint);
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
- // TODO: impl
- }
-}
diff --git
a/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/tabular/ZooSoftmaxRegressionPredictor.java
b/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/tabular/ZooSoftmaxRegressionPredictor.java
deleted file mode 100644
index ee2f684e5c58..000000000000
---
a/components/camel-ai/camel-djl/src/main/java/org/apache/camel/component/djl/model/tabular/ZooSoftmaxRegressionPredictor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.djl.model.tabular;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.component.djl.DJLEndpoint;
-import org.apache.camel.component.djl.model.AbstractPredictor;
-
-public class ZooSoftmaxRegressionPredictor extends AbstractPredictor {
- public ZooSoftmaxRegressionPredictor(DJLEndpoint endpoint) {
- super(endpoint);
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
- // TODO: impl
- }
-}
diff --git
a/components/camel-ai/camel-djl/src/test/java/org/apache/camel/component/djl/model/ModelPredictorProducerTest.java
b/components/camel-ai/camel-djl/src/test/java/org/apache/camel/component/djl/model/ModelPredictorProducerTest.java
index a4ab4000ceb9..ac36192ccf5a 100644
---
a/components/camel-ai/camel-djl/src/test/java/org/apache/camel/component/djl/model/ModelPredictorProducerTest.java
+++
b/components/camel-ai/camel-djl/src/test/java/org/apache/camel/component/djl/model/ModelPredictorProducerTest.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import ai.djl.MalformedModelException;
import ai.djl.repository.zoo.ModelNotFoundException;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.djl.DJLEndpoint;
import org.apache.camel.component.djl.model.audio.CustomAudioPredictor;
import org.apache.camel.component.djl.model.cv.CustomCvPredictor;
@@ -45,6 +46,8 @@ import org.junit.jupiter.api.Test;
import static
org.apache.camel.component.djl.model.ModelPredictorProducer.getCustomPredictor;
import static
org.apache.camel.component.djl.model.ModelPredictorProducer.getZooPredictor;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class ModelPredictorProducerTest {
@@ -88,9 +91,7 @@ class ModelPredictorProducerTest {
// No builtin zoo model available for "nlp/multiple_choice"
// No builtin zoo model available for "nlp/text_embedding"
- // Tabular
- // No builtin zoo model available for "tabular/linear_regression"
- // No builtin zoo model available for "tabular/softmax_regression"
+ // Tabular: no zoo predictor exists (see
testGetZooPredictorRejectsTabularApplications)
// Audio
// No builtin zoo model available for "audio"
@@ -100,6 +101,19 @@ class ModelPredictorProducerTest {
getZooPredictor(zooEndpoint("timeseries/forecasting",
"ai.djl.pytorch:deepar:0.0.1")));
}
+ @Test
+ void testGetZooPredictorRejectsTabularApplications() {
+ // The DJL model zoo publishes no tabular regression models and
tabular I/O types are
+ // model-specific, so the zoo predictor factory must reject these
applications with a clear
+ // error rather than returning a no-op predictor that echoes the input
as the prediction.
+ RuntimeCamelException linear =
assertThrows(RuntimeCamelException.class,
+ () -> getZooPredictor(zooEndpoint("tabular/linear_regression",
"any:artifact:0.0.1")));
+ assertTrue(linear.getMessage().contains("tabular/linear_regression"));
+ RuntimeCamelException softmax =
assertThrows(RuntimeCamelException.class,
+ () ->
getZooPredictor(zooEndpoint("tabular/softmax_regression",
"any:artifact:0.0.1")));
+
assertTrue(softmax.getMessage().contains("tabular/softmax_regression"));
+ }
+
@Test
void testGetCustomPredictor() {
var modelName = "MyModel";