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


##########
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):

Review Comment:
   If we do this we would really need to document what return_row does.
   
   What I would prefer, is since we can still change our apis we should use one 
interface or the other.
   
   What do you think of the idea of only using one or the other beam.rows or 
the PredictionResult dataclass?



##########
sdks/python/apache_beam/ml/inference/api.py:
##########
@@ -17,16 +17,17 @@
 # mypy: ignore-errors
 
 from dataclasses import dataclass
-from typing import Tuple
-from typing import TypeVar
-from typing import Union
+from typing import Callable
 
 import apache_beam as beam
 from apache_beam.ml.inference import base
+from apache_beam.typehints import Tuple

Review Comment:
   I asked @robertwb about this in https://github.com/apache/beam/pull/17762.  
He thought that we should prefer native types.  Does that sound right?



##########
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:
   I don't get this. Is this for some callable that returns a model loader?  
Where would we use this instead of just passing in a model loader?



-- 
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