Skip to content

Commit e17028d

Browse files
authored
fix: Create __init__ files for the proto-generated python dirs (feast-dev#2410)
* fix: Create __init__ files for the proto-generated python dirs Signed-off-by: Achal Shah <achals@gmail.com> * remove dupe import Signed-off-by: Achal Shah <achals@gmail.com>
1 parent 37ab13b commit e17028d

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ package-protos:
4646
cp -r ${ROOT_DIR}/protos ${ROOT_DIR}/sdk/python/feast/protos
4747

4848
compile-protos-python:
49-
python setup.py build_python_protos
49+
python sdk/python/setup.py build_python_protos
5050

5151
install-python:
5252
cd sdk/python && python -m piptools sync requirements/py$(PYTHON)-requirements.txt

sdk/python/setup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,14 @@ def _generate_python_protos(self, path: str):
215215
def run(self):
216216
for sub_folder in self.sub_folders:
217217
self._generate_python_protos(f"feast/{sub_folder}/*.proto")
218-
219-
from pathlib import Path
218+
# We need the __init__ files for each of the generated subdirs
219+
# so that they are regular packages, and don't need the `--namespace-packages` flags
220+
# when being typechecked using mypy. BUT, we need to exclude `types` because that clashes
221+
# with an existing module in the python standard library.
222+
if sub_folder == "types":
223+
continue
224+
with open(f"{self.python_folder}/feast/{sub_folder}/__init__.py", 'w'):
225+
pass
220226

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

0 commit comments

Comments
 (0)