forked from mlflow/mlflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-protos.sh
executable file
·31 lines (27 loc) · 1.3 KB
/
generate-protos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
set -ex
PROTOC_VERSION="$(protoc --version)"
if [[ "$PROTOC_VERSION" != 'libprotoc 3.6.0' && "$PROTOC_VERSION" != 'libprotoc 3.6.1' ]]; then
echo "Required libprotoc versions to be 3.6.0 or 3.6.1 (preferred)."
echo "We found: $PROTOC_VERSION"
exit 1
fi
PROTOS="mlflow/protos"
protoc -I="$PROTOS" \
--python_out="$PROTOS" \
--java_out="mlflow/java/client/src/main/java" \
"$PROTOS"/databricks.proto \
"$PROTOS"/service.proto \
"$PROTOS"/model_registry.proto \
"$PROTOS"/databricks_artifacts.proto \
"$PROTOS"/scalapb/scalapb.proto
OLD_SCALAPB="from scalapb import scalapb_pb2 as scalapb_dot_scalapb__pb2"
NEW_SCALAPB="from .scalapb import scalapb_pb2 as scalapb_dot_scalapb__pb2"
sed -i'.old' -e "s/$OLD_SCALAPB/$NEW_SCALAPB/g" "$PROTOS/databricks_pb2.py" "$PROTOS/service_pb2.py" "$PROTOS/model_registry_pb2.py" "$PROTOS/databricks_artifacts_pb2.py"
OLD_DATABRICKS="import databricks_pb2 as databricks__pb2"
NEW_DATABRICKS="from . import databricks_pb2 as databricks__pb2"
sed -i'.old' -e "s/$OLD_DATABRICKS/$NEW_DATABRICKS/g" "$PROTOS/service_pb2.py" "$PROTOS/model_registry_pb2.py" "$PROTOS/databricks_artifacts_pb2.py"
rm "$PROTOS/databricks_pb2.py.old"
rm "$PROTOS/service_pb2.py.old"
rm "$PROTOS/model_registry_pb2.py.old"
rm "$PROTOS/databricks_artifacts_pb2.py.old"