liferoad commented on code in PR #31604:
URL: https://github.com/apache/beam/pull/31604#discussion_r1643536017


##########
sdks/python/apache_beam/yaml/yaml_provider.py:
##########
@@ -1153,18 +1158,35 @@ def cache_artifacts(self):
     self._underlying_provider.cache_artifacts()
 
 
-def parse_providers(provider_specs):
-  providers = collections.defaultdict(list)
+def flatten_included_provider_specs(
+    provider_specs: Iterable[Mapping]) -> Iterator[Mapping]:
   for provider_spec in provider_specs:
-    provider = ExternalProvider.provider_from_spec(provider_spec)
-    for transform_type in provider.provided_transforms():
-      providers[transform_type].append(provider)
-      # TODO: Do this better.
-      provider.to_json = lambda result=provider_spec: result
-  return providers
+    if 'include' in provider_spec:
+      if len(provider_spec) != 1:
+        raise ValueError(f"Invalid provider spec: {provider_spec}")
+      try:
+        with urllib.request.urlopen(provider_spec['include']) as response:
+          content = response.read()
+      except (ValueError, urllib.error.URLError) as exn:
+        if 'unknown url type' in str(exn):
+          with FileSystems.open(provider_spec['include']) as fin:
+            content = fin.read()
+        else:
+          raise

Review Comment:
   shall we raise a runtime error here?



-- 
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-unsubscr...@beam.apache.org

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

Reply via email to