ryanthompson591 commented on a change in pull request #16970:
URL: https://github.com/apache/beam/pull/16970#discussion_r818631705
##########
File path: sdks/python/apache_beam/ml/inference/base.py
##########
@@ -0,0 +1,194 @@
+import logging
+import platform
+import resource
+import sys
+import time
+from typing import Any
+from typing import List
+
+import apache_beam as beam
+from apache_beam.utils import shared
+from apache_beam.ml.inference.apis import PredictionResult
+
+_MILLISECOND_TO_MICROSECOND = 1000
+_MICROSECOND_TO_NANOSECOND = 1000
+_SECOND_TO_MICROSECOND = 1000000
+
+
+def _unbatch(maybe_keyed_batches: Any):
+ keys, results = maybe_keyed_batches
+ if keys:
+ return zip(keys, results)
+ else:
+ return results
+
+
+class ModelLoader:
+ """Has the ability to load an ML model."""
+ def load_model(self):
+ """Loads an initializes a model for processing."""
+ raise NotImplementedError(type(self))
+
+
+class InferenceRunner:
+ """Implements running inferences for a framework."""
+ def run_inference(self, batch: Any, model: Any) -> List[PredictionResult]:
Review comment:
Yeah, I like Iterable, it is more generic. Done.
--
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]