AnandInguva commented on code in PR #29938:
URL: https://github.com/apache/beam/pull/29938#discussion_r1450898762
##########
sdks/python/apache_beam/ml/transforms/base_test.py:
##########
@@ -588,5 +590,51 @@ def test_with_same_local_artifact_location(self):
artifact_location=artifact_location)
+class MLTransformDLQTest(unittest.TestCase):
+ def setUp(self) -> None:
+ self.artifact_location = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self.artifact_location)
+
+ def test_dlq_with_embeddings(self):
+ with beam.Pipeline() as p:
+ good, bad = (
+ p
+ | beam.Create([{
+ 'x': 1
+ },
+ {
+ 'x': 3,
+ },
+ {
+ 'x': 'Hello'
+ }
+ ],
+ )
+ | base.MLTransform(
+ write_artifact_location=self.artifact_location).with_transform(
+ FakeEmbeddingsManager(
+ columns=['x'])).with_exception_handling())
+
+ good_expected_elements = [{'x': 'olleH'}]
+
+ assert_that(
+ good,
+ equal_to(good_expected_elements),
+ label='good',
+ )
+
+ # batching happens in RunInference hence elements
+ # are in lists in the bad pcoll.
Review Comment:
>> I don't think this comment makes sense, the errors are because we're
throwing on non-strings, right?
IIUC, Yes, that is right(throwing error on non-strings) but in
`RunInference`, the scalars/strings are converted to List using
beam.BatchElements, and when that error occurs, the list is sent to DLQ.
--
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]