Skip to content

Commit

Permalink
fix: Create __init__ files for the proto-generated python dirs (#2410)
Browse files Browse the repository at this point in the history
* fix: Create __init__ files for the proto-generated python dirs

Signed-off-by: Achal Shah <[email protected]>

* remove dupe import

Signed-off-by: Achal Shah <[email protected]>
  • Loading branch information
achals authored Mar 15, 2022
1 parent 37ab13b commit e17028d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ package-protos:
cp -r ${ROOT_DIR}/protos ${ROOT_DIR}/sdk/python/feast/protos

compile-protos-python:
python setup.py build_python_protos
python sdk/python/setup.py build_python_protos

install-python:
cd sdk/python && python -m piptools sync requirements/py$(PYTHON)-requirements.txt
Expand Down
10 changes: 8 additions & 2 deletions sdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,14 @@ def _generate_python_protos(self, path: str):
def run(self):
for sub_folder in self.sub_folders:
self._generate_python_protos(f"feast/{sub_folder}/*.proto")

from pathlib import Path
# We need the __init__ files for each of the generated subdirs
# so that they are regular packages, and don't need the `--namespace-packages` flags
# when being typechecked using mypy. BUT, we need to exclude `types` because that clashes
# with an existing module in the python standard library.
if sub_folder == "types":
continue
with open(f"{self.python_folder}/feast/{sub_folder}/__init__.py", 'w'):
pass

for path in Path("feast/protos").rglob("*.py"):
for folder in self.sub_folders:
Expand Down

0 comments on commit e17028d

Please sign in to comment.