From a676b43def0b399fe5d881da6eeb420e070e3b51 Mon Sep 17 00:00:00 2001 From: Achal Shah Date: Tue, 15 Mar 2022 11:23:03 -0700 Subject: [PATCH 1/2] fix: Create __init__ files for the proto-generated python dirs Signed-off-by: Achal Shah --- Makefile | 2 +- sdk/python/setup.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 15ac9304723..f65d07bbdf1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/sdk/python/setup.py b/sdk/python/setup.py index e4fe7ea9468..da624ae4043 100644 --- a/sdk/python/setup.py +++ b/sdk/python/setup.py @@ -210,13 +210,21 @@ def _generate_python_protos(self, path: str): self.python_folder, ] + proto_files, - ) + ) def run(self): + from pathlib import Path + 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: From 507cf5a4d60f6001c29486f794f6e10bcf8df138 Mon Sep 17 00:00:00 2001 From: Achal Shah Date: Tue, 15 Mar 2022 12:14:59 -0700 Subject: [PATCH 2/2] remove dupe import Signed-off-by: Achal Shah --- sdk/python/setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk/python/setup.py b/sdk/python/setup.py index da624ae4043..3d4576c19e3 100644 --- a/sdk/python/setup.py +++ b/sdk/python/setup.py @@ -210,11 +210,9 @@ def _generate_python_protos(self, path: str): self.python_folder, ] + proto_files, - ) + ) def run(self): - from pathlib import Path - for sub_folder in self.sub_folders: self._generate_python_protos(f"feast/{sub_folder}/*.proto") # We need the __init__ files for each of the generated subdirs