ihji commented on code in PR #17773:
URL: https://github.com/apache/beam/pull/17773#discussion_r891788348


##########
sdks/python/apache_beam/ml/inference/api.py:
##########
@@ -52,8 +52,12 @@ class RunInference(beam.PTransform):
 
   TODO(BEAM-14046): Add and link to help documentation
   """
-  def __init__(self, model_loader: base.ModelLoader):
-    self._model_loader = model_loader
+  def __init__(
+      self, model_loader: Union[base.ModelLoader, Callable], return_row=False):
+    self._model_loader = model_loader() if isinstance(

Review Comment:
   Adding `create` method so that we could separate the class constructor and 
the arguments. The low-level API from the Java SDK would look like:
   ```
   
PythonExternalTransform.from("apache_beam.ml.inference.api.RunInference.create")
       .withKwarg("model_loader_provider", PythonCallableSource.of(
           "from apache_beam.ml.inference.sklearn_inference import 
SklearnModelLoader\nSklearnModelLoader"))
       .withKwarg("model_uri", "/tmp/staged/sklearn_model")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to