damccorm commented on code in PR #35709: URL: https://github.com/apache/beam/pull/35709#discussion_r2240212092
########## 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: Lets either rework it in this PR or do something simpler here with a basic try/catch. Ideally, we'd just fix it here though, as it stands this isn't a great example -- 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]
