derrickaw commented on code in PR #35715:
URL: https://github.com/apache/beam/pull/35715#discussion_r2240680436
##########
sdks/python/apache_beam/yaml/yaml_ml.py:
##########
@@ -29,11 +31,28 @@
from apache_beam.yaml import options
from apache_beam.yaml.yaml_utils import SafeLineLoader
+
+def list_submodules(package):
+ """
+ Lists all submodules within a given package.
+ """
+ submodules = []
+ for _, module_name, _ in pkgutil.walk_packages(
+ package.__path__, package.__name__ + '.'):
+ if 'test' in module_name:
+ continue
+ submodules.append(module_name)
+ return submodules
+
+
try:
from apache_beam.ml.transforms import tft
from apache_beam.ml.transforms.base import MLTransform
# TODO(robertwb): Is this all of them?
- _transform_constructors = tft.__dict__
+ _transform_constructors = {}
+ for module_name in list_submodules(beam.ml.transforms):
+ module = import_module(module_name)
+ _transform_constructors |= module.__dict__
except ImportError:
Review Comment:
Thats correct. Let me rethink this.
--
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]