You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "byronellis (via GitHub)" <gi...@apache.org> on 2023/09/18 16:05:26 UTC

[GitHub] [beam] byronellis commented on a diff in pull request #28289: Better errors when inputs are omitted.

byronellis commented on code in PR #28289:
URL: https://github.com/apache/beam/pull/28289#discussion_r1328944486


##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -61,6 +61,16 @@ def provided_transforms(self) -> Iterable[str]:
     """Returns a list of transform type names this provider can handle."""
     raise NotImplementedError(type(self))
 
+  def requires_inputs(self, typ: str, args: Mapping[str, Any]) -> bool:
+    """Returns whether this transform requires inputs.
+
+    Specifically, if this returns True and inputs are not provided than an error
+    will be thrown.
+
+    This is best-effort, primarily for better and earlier error messages.
+    """
+    return not typ.startswith('Read')

Review Comment:
   Presuming this is to provide a reasonable default? Seems like it might lead to surprising false positives though?



##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -138,8 +146,19 @@ def create_transform(self, type, args, yaml_create_transform):
       except Exception:
         # It's possible this service doesn't vend schema transforms.
         self._schema_transforms = {}
+    return self._schema_transforms
+
+  def requires_inputs(self, typ, args):
+    if self._urns[type] in self.schema_transforms():
+      return bool(self.schema_transforms()[self._urns[type]].inputs)

Review Comment:
   Unfortunately relying on schema transform's inputs/outputs is not very reliable (and maybe completely unreliable). They do not depend on the configuration passed to the transforms making them basically useless for determining anything other than inputs/outputs that are present in all possible configurations.



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org