github-actions[bot] commented on code in PR #41453:
URL: https://github.com/apache/beam/pull/41453#discussion_r4741980456


##########
sdks/python/apache_beam/yaml/yaml_enrichment.py:
##########
@@ -104,5 +125,32 @@ def enrichment_transform(
   if enrichment_handler not in handler_map:
     raise ValueError(f"Unknown enrichment source: {enrichment_handler}")
 
+  if handler_map[enrichment_handler] is None:
+    raise ValueError(
+        f"gcp dependencies not installed. Cannot use {enrichment_handler} "
+        f"handler. Please install using 'pip install apache-beam[gcp]'.")
+
   handler = handler_map[enrichment_handler](**handler_config)
-  return pcoll | Enrichment(source_handler=handler, timeout=timeout)
+  # on_miss/prefix land in a follow-up to #41451. Build kwargs dynamically so
+  # type checkers against current master Enrichment stay clean, and raise if
+  # the YAML asks for those options before that API is available.
+  # error_handling uses Enrichment.with_exception_handling from #41451 via
+  # maybe_with_exception_handling_transform_fn / _PValueWithErrors.
+  enrich_kwargs: dict[str, Any] = {
+      'source_handler': handler,
+      'timeout': timeout,
+  }
+  enrich_params = inspect.signature(Enrichment.__init__).parameters
+  if 'on_miss' in enrich_params:
+    enrich_kwargs['on_miss'] = on_miss
+  elif on_miss not in (None, 'null'):

Review Comment:
   **🟢 Low**: Avoid referencing local/author-specific git branch names 
(`feat-enrichment-on-miss-prefix-followup-41356`) in user-facing runtime 
`ValueError` messages (here and on line 153). If this PR is merged before the 
`on_miss`/`prefix` follow-up PR, users who configure these documented 
parameters will see an internal branch name in the exception.
   
   ```suggestion
           "Enrichment does not support on_miss yet (tracked in #41356).")
   ```



##########
sdks/python/apache_beam/yaml/yaml_enrichment_test.py:
##########
@@ -15,33 +15,92 @@
 # limitations under the License.
 #
 
+import inspect
 import logging
+import os
+import tempfile
 import unittest
 
 import mock
 
 import apache_beam as beam
 from apache_beam import Row
+from apache_beam.io.requestresponse import UserCodeTimeoutException
 from apache_beam.testing.util import assert_that
 from apache_beam.testing.util import equal_to
+from apache_beam.transforms.enrichment import Enrichment
+from apache_beam.transforms.enrichment import EnrichmentSourceHandler
 from apache_beam.yaml import yaml_provider
+from apache_beam.yaml.yaml_enrichment import FileEnrichmentHandler
 from apache_beam.yaml.yaml_transform import YamlTransform
 
+try:
+  import pyarrow as pa
+  import pyarrow.parquet as pq
+except ImportError:
+  pa = None  # type: ignore[assignment]
+  pq = None  # type: ignore[assignment]
+
 

Review Comment:
   **🟡 Medium**: `_HAS_ENRICHMENT_DLQ_AND_FILE` requires 
`FileEnrichmentHandler`, `Enrichment.with_exception_handling`, and `on_miss` in 
`Enrichment.__init__` simultaneously. Since `on_miss` and `prefix` were split 
out of #41451 into a separate follow-up, 
`test_enrichment_with_file_handler_and_prefix` (which only needs 
`FileEnrichmentHandler` and `prefix`) and any test exercising `error_handling` 
with `with_exception_handling` will remain skipped even after #41451 and #41452 
merge. Consider splitting the skip conditions or adding a unit test with a mock 
`Enrichment` / handler so the new `yaml_enrichment.py` branches are covered in 
CI.



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