Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change package and path in protobuf model #43

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ repos:
- grpcio-tools
- types-Pygments
- types-protobuf
exclude: "^src/neptune_api/proto/"
exclude: "^src/(neptune_api|neptune_retrieval_api)/proto/"
default_language_version:
python: python3
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ exclude = ["src/neptune_api/proto", "src/neptune_retrieval_api/proto"]
select = ["F", "UP"]

[tool.mypy]
files = 'src/neptune_api'
files = ['src/neptune_api', 'src/neptune_retrieval_api']
mypy_path = "stubs"
install_types = "True"
non_interactive = "True"
Expand Down
40 changes: 40 additions & 0 deletions scripts/generate_proto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -euxo pipefail

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
SRC_DIR="${SCRIPT_DIR}/../src"
NEPTUNE_PROJECT_DIR="${1:-}"

if [ -z "${NEPTUNE_PROJECT_DIR}" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please have an env pointing to ${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto? I'd prefer to limit how much our repo structure is exposed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

echo "Usage: $0 <neptune_project_dir>"
exit 1
fi

python -m grpc_tools.protoc \
--python_out="${SRC_DIR}/neptune_api/proto" \
--mypy_out="${SRC_DIR}/neptune_api/proto" \
--proto_path="${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto" \
"${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto/google_rpc/"*".proto" \
"${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto/neptune_pb/ingest/v1/"*".proto" \
"${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto/neptune_pb/ingest/v1/pub/"*".proto"

python -m grpc_tools.protoc \
--python_out="${SRC_DIR}/neptune_retrieval_api/proto" \
--mypy_out="${SRC_DIR}/neptune_retrieval_api/proto" \
--proto_path="${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto" \
"${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto/neptune_pb/api/v1/model/"*".proto"

protol --create-package --in-place \
--python-out "${SRC_DIR}/neptune_api/proto" \
protoc \
--proto-path "${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto" \
"${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto/google_rpc/"*".proto" \
"${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto/neptune_pb/ingest/v1/"*".proto" \
"${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto/neptune_pb/ingest/v1/pub/"*".proto"

protol --create-package --in-place \
--python-out "${SRC_DIR}/neptune_retrieval_api/proto" \
protoc \
--proto-path "${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto" \
"${NEPTUNE_PROJECT_DIR}/libs/models/leaderboard-proto/src/main/proto/neptune_pb/api/v1/model/"*".proto"
6 changes: 1 addition & 5 deletions src/neptune_api/proto/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
from . import (
google_rpc,
neptune_pb,
)
from . import google_rpc
from . import neptune_pb
from . import google_rpc
4 changes: 2 additions & 2 deletions src/neptune_api/proto/google_rpc/code_pb2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'google_rpc.code_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
_globals['DESCRIPTOR']._loaded_options = None
if _descriptor._USE_C_DESCRIPTORS == False:
_globals['DESCRIPTOR']._options = None
_globals['DESCRIPTOR']._serialized_options = b'\n\x0ecom.google.rpcB\tCodeProtoP\x01Z3google.golang.org/genproto/googleapis/rpc/code;code\xa2\x02\x03RPC'
_globals['_CODE']._serialized_start = 38
_globals['_CODE']._serialized_end = 349
2 changes: 1 addition & 1 deletion src/neptune_api/proto/neptune_pb/ingest/v1/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import pub
from . import common_pb2
from . import ingest_pb2
from . import pub
5 changes: 1 addition & 4 deletions src/neptune_retrieval_api/proto/neptune_pb/api/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
from . import (
fields_pb2,
model,
)
from . import v1
33 changes: 0 additions & 33 deletions src/neptune_retrieval_api/proto/neptune_pb/api/fields_pb2.py

This file was deleted.

Loading
Loading