AnandInguva commented on code in PR #28385:
URL: https://github.com/apache/beam/pull/28385#discussion_r1344319886
##########
sdks/python/gen_protos.py:
##########
@@ -539,39 +499,44 @@ def generate_proto_files(force=False):
'Protoc returned non-zero status (see logs for details): '
'%s' % ret_code)
- # copy resource files
- for path in MODEL_RESOURCES:
- shutil.copy2(os.path.join(PROJECT_ROOT, path), PYTHON_OUTPUT_PATH)
-
- proto_packages = set()
- # see: https://github.com/protocolbuffers/protobuf/issues/1491
- # force relative import paths for proto files
- compiled_import_re = re.compile('^from (.*) import (.*)$')
- for file_path in find_by_ext(PYTHON_OUTPUT_PATH,
- ('_pb2.py', '_pb2_grpc.py', '_pb2.pyi')):
- proto_packages.add(os.path.dirname(file_path))
- lines = []
- with open(file_path, encoding='utf-8') as f:
- for line in f:
- match_obj = compiled_import_re.match(line)
- if match_obj and \
- match_obj.group(1).startswith('org.apache.beam.model'):
- new_import = build_relative_import(
- PYTHON_OUTPUT_PATH, match_obj.group(1), file_path)
- line = 'from %s import %s\n' % (new_import, match_obj.group(2))
-
- lines.append(line)
-
- with open(file_path, 'w') as f:
- f.writelines(lines)
-
- generate_init_files_lite(PYTHON_OUTPUT_PATH)
- with PythonPath(grpcio_install_loc):
+ # copy resource files
+ for path in MODEL_RESOURCES:
+ shutil.copy2(os.path.join(PROJECT_ROOT, path), PYTHON_OUTPUT_PATH)
+
+ proto_packages = set()
+ # see: https://github.com/protocolbuffers/protobuf/issues/1491
+ # force relative import paths for proto files
+ compiled_import_re = re.compile('^from (.*) import (.*)$')
+ for file_path in find_by_ext(PYTHON_OUTPUT_PATH,
+ ('_pb2.py', '_pb2_grpc.py', '_pb2.pyi')):
+ proto_packages.add(os.path.dirname(file_path))
+ lines = []
+ with open(file_path, encoding='utf-8') as f:
+ for line in f:
+ match_obj = compiled_import_re.match(line)
+ if match_obj and \
+ match_obj.group(1).startswith('org.apache.beam.model'):
+ new_import = build_relative_import(
+ PYTHON_OUTPUT_PATH, match_obj.group(1), file_path)
+ line = 'from %s import %s\n' % (new_import, match_obj.group(2))
+
+ lines.append(line)
+
+ with open(file_path, 'w') as f:
+ f.writelines(lines)
+
+ generate_init_files_lite(PYTHON_OUTPUT_PATH)
for proto_package in proto_packages:
generate_urn_files(proto_package, PYTHON_OUTPUT_PATH)
- generate_init_files_full(PYTHON_OUTPUT_PATH)
+ generate_init_files_full(PYTHON_OUTPUT_PATH)
+ except ImportError:
Review Comment:
Actually, I missed this comment. This looks a little off. We don't need this
ImportError anymore
--
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]