Skip to content

Commit 81403e1

Browse files
authored
fix: change package and path in protobuf model (#43)
* fix: package change * fix: wrong import * fix: prefer direct path to pb files in script --------- Co-authored-by: Michał Sośnicki <michal.sosnicki@neptune.ai>
1 parent ac45f73 commit 81403e1

26 files changed

+669
-1245
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ repos:
3333
- grpcio-tools
3434
- types-Pygments
3535
- types-protobuf
36-
exclude: "^src/neptune_api/proto/"
36+
exclude: "^src/(neptune_api|neptune_retrieval_api)/proto/"
3737
default_language_version:
3838
python: python3

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ exclude = ["src/neptune_api/proto", "src/neptune_retrieval_api/proto"]
8484
select = ["F", "UP"]
8585

8686
[tool.mypy]
87-
files = 'src/neptune_api'
87+
files = ['src/neptune_api', 'src/neptune_retrieval_api']
8888
mypy_path = "stubs"
8989
install_types = "True"
9090
non_interactive = "True"

scripts/generate_proto.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
6+
SRC_DIR="${SCRIPT_DIR}/../src"
7+
PROTOBUF_SRC_DIR="${1:-}"
8+
9+
if [ -z "${PROTOBUF_SRC_DIR}" ]; then
10+
echo "Usage: $0 <protobuf_src_dir>"
11+
exit 1
12+
fi
13+
14+
python -m grpc_tools.protoc \
15+
--python_out="${SRC_DIR}/neptune_api/proto" \
16+
--mypy_out="${SRC_DIR}/neptune_api/proto" \
17+
--proto_path="${PROTOBUF_SRC_DIR}" \
18+
"${PROTOBUF_SRC_DIR}/google_rpc/"*".proto" \
19+
"${PROTOBUF_SRC_DIR}/neptune_pb/ingest/v1/"*".proto" \
20+
"${PROTOBUF_SRC_DIR}/neptune_pb/ingest/v1/pub/"*".proto"
21+
22+
python -m grpc_tools.protoc \
23+
--python_out="${SRC_DIR}/neptune_retrieval_api/proto" \
24+
--mypy_out="${SRC_DIR}/neptune_retrieval_api/proto" \
25+
--proto_path="${PROTOBUF_SRC_DIR}" \
26+
"${PROTOBUF_SRC_DIR}/neptune_pb/api/v1/model/"*".proto"
27+
28+
protol --create-package --in-place \
29+
--python-out "${SRC_DIR}/neptune_api/proto" \
30+
protoc \
31+
--proto-path "${PROTOBUF_SRC_DIR}" \
32+
"${PROTOBUF_SRC_DIR}/google_rpc/"*".proto" \
33+
"${PROTOBUF_SRC_DIR}/neptune_pb/ingest/v1/"*".proto" \
34+
"${PROTOBUF_SRC_DIR}/neptune_pb/ingest/v1/pub/"*".proto"
35+
36+
protol --create-package --in-place \
37+
--python-out "${SRC_DIR}/neptune_retrieval_api/proto" \
38+
protoc \
39+
--proto-path "${PROTOBUF_SRC_DIR}" \
40+
"${PROTOBUF_SRC_DIR}/neptune_pb/api/v1/model/"*".proto"

src/neptune_api/proto/__init__.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
from . import (
2-
google_rpc,
3-
neptune_pb,
4-
)
5-
from . import google_rpc
61
from . import neptune_pb
2+
from . import google_rpc

src/neptune_api/proto/google_rpc/code_pb2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
_globals = globals()
99
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
1010
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'google_rpc.code_pb2', _globals)
11-
if not _descriptor._USE_C_DESCRIPTORS:
12-
_globals['DESCRIPTOR']._loaded_options = None
11+
if _descriptor._USE_C_DESCRIPTORS == False:
12+
_globals['DESCRIPTOR']._options = None
1313
_globals['DESCRIPTOR']._serialized_options = b'\n\x0ecom.google.rpcB\tCodeProtoP\x01Z3google.golang.org/genproto/googleapis/rpc/code;code\xa2\x02\x03RPC'
1414
_globals['_CODE']._serialized_start = 38
1515
_globals['_CODE']._serialized_end = 349
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from . import pub
21
from . import common_pb2
32
from . import ingest_pb2
3+
from . import pub
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
from . import (
2-
fields_pb2,
3-
model,
4-
)
1+
from . import v1

src/neptune_retrieval_api/proto/neptune_pb/api/fields_pb2.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)