damccorm commented on code in PR #35709:
URL: https://github.com/apache/beam/pull/35709#discussion_r2237080122


##########
sdks/python/apache_beam/examples/inference/gemini_text_classification.py:
##########
@@ -67,8 +67,24 @@ def parse_known_args(argv):
 
 class PostProcessor(beam.DoFn):
   def process(self, element: PredictionResult) -> Iterable[str]:
-    yield "Input: " + str(element.example) + " Output: " + str(
-        element.inference[1][0].content.parts[0].text)
+
+    inference = getattr(element, "inference", None)
+
+    if not isinstance(inference, (tuple, list)) or len(inference) < 2:
+      yield "Can't decode inference for element: " + str(element.example)

Review Comment:
   Is the shape of the returned object actually different? Can we update the 
example to correctly extract the data here instead of just ignoring data?



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