-
Notifications
You must be signed in to change notification settings - Fork 487
Open
Labels
Description
What you would like to be added?
This issue is created to track the tricky import changes in Python SDK.
Currently, we have no choice but to do the tricky import changes because: #2398 (comment) .
Lines 169 to 179 in a524f33
# TODO(Electronic-Waste): Remove the import rewrite when protobuf supports `python_package` option. | |
# REF: https://github.com/protocolbuffers/protobuf/issues/7061 | |
pytest: prepare-pytest prepare-pytest-testdata | |
pytest ./test/unit/v1beta1/suggestion --ignore=./test/unit/v1beta1/suggestion/test_skopt_service.py | |
pytest ./test/unit/v1beta1/earlystopping | |
pytest ./test/unit/v1beta1/metricscollector | |
cp ./pkg/apis/manager/v1beta1/python/api_pb2.py ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2.py | |
cp ./pkg/apis/manager/v1beta1/python/api_pb2_grpc.py ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2_grpc.py | |
sed -i "s/api_pb2/kubeflow\.katib\.katib_api_pb2/g" ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2_grpc.py | |
pytest ./sdk/python/v1beta1/kubeflow/katib | |
rm ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2.py ./sdk/python/v1beta1/kubeflow/katib/katib_api_pb2_grpc.py |
katib/sdk/python/v1beta1/setup.py
Lines 41 to 54 in a524f33
# TODO(Electronic-Waste): Remove the import rewrite when protobuf supports `python_package` option. | |
# REF: https://github.com/protocolbuffers/protobuf/issues/7061 | |
if os.path.exists(katib_grpc_svc_file): | |
shutil.copy( | |
katib_grpc_svc_file, | |
"kubeflow/katib/katib_api_pb2_grpc.py", | |
) | |
with open("kubeflow/katib/katib_api_pb2_grpc.py", "r+") as file: | |
content = file.read() | |
new_content = content.replace("api_pb2", "kubeflow.katib.katib_api_pb2") | |
file.seek(0) | |
file.write(new_content) | |
file.truncate() |
Why is this needed?
As I described in #2398 (comment) , we need to discard the tricky import changes when protocolbuffers/protobuf#7061 supports options like python_package
to mutate the importing package name.
Love this feature?
Give it a 👍 We prioritize the features with most 👍
Electronic-Waste and andreyvelich