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


##########
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:
   Is there an advantage to raising a RuntimeError rather than preserving the 
specific error that fetching the URL produced? 



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