You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2023/01/13 15:30:11 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #24993: Fix example checker validation for incomplete multifile examples

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


##########
playground/infrastructure/helper.py:
##########
@@ -188,13 +188,20 @@ def get_tag(filepath) -> Optional[Tag]:
         line[len(tag_prefix) :] for line in lines[line_start:line_finish]
     )
     yml = yaml.load(embdedded_yaml_content, Loader=yaml.SafeLoader)
-    return Tag(
-        filepath=filepath,
-        line_start=line_start,
-        line_finish=line_finish,
-        **yml[Config.BEAM_PLAYGROUND],
-    )
 
+    try:
+        return Tag(
+            filepath=str(filepath),
+            line_start=line_start,
+            line_finish=line_finish,
+            **yml[Config.BEAM_PLAYGROUND],
+            )
+    except pydantic.ValidationError as err:
+        if len(err.errors()) > 1:
+            raise
+        if err.errors()[0]["msg"] == "multifile is True but no files defined":
+            logging.warning("incomplete multifile example ignored %s", filepath)
+            return None

Review Comment:
   If this condition isn't true `err.errors()[0]["msg"] == "multifile is True but no files defined"` we still want to raise an exception, right?
   
   Should this just be:
   
   ```
           if len(err.errors()) == 1 and err.errors()[0]["msg"] == "multifile is True but no files defined":
               logging.warning("incomplete multifile example ignored %s", filepath)
               return None
           raise
   ```



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