Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jopel committed Dec 5, 2024
1 parent 670afcb commit fb3c5c3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion scripts/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
INLINE_OPTIMIZATION = True
FILE_PATH_PREFIX = "snowflake.telemetry._internal"
FILE_NAME_SUFFIX = "_marshaler"
OPENTELEMETRY_PROTO_DIR = os.environ["OPENTELEMETRY_PROTO_DIR"]

# Inline utility functions

Expand Down Expand Up @@ -293,7 +294,7 @@ def from_descriptor(descriptor: FileDescriptorProto) -> "FileTemplate":
# In the case of the opentelemetry-proto files, the preamble is the license header
# Each line of the preamble is prefixed with "//"
preamble = ""
with open(f'/tmp/opentelemetry-proto/{descriptor.name}', "r") as f:
with open(f'{OPENTELEMETRY_PROTO_DIR}/{descriptor.name}', "r") as f:
line = f.readline()
while line and line.startswith("//"):
preamble += line.replace("//", "#", 1)
Expand Down
2 changes: 1 addition & 1 deletion scripts/proto_codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ find opentelemetry/proto/ -regex ".*_marshaler\.py" -exec rm {} +

# generate proto code for all protos
all_protos=$(find $PROTO_REPO_DIR/ -iname "*.proto")
python -m grpc_tools.protoc \
OPENTELEMETRY_PROTO_DIR=$PROTO_REPO_DIR python -m grpc_tools.protoc \
-I $PROTO_REPO_DIR \
--plugin=protoc-gen-custom-plugin=$repo_root/scripts/plugin.py \
--custom-plugin_out=. \
Expand Down
2 changes: 2 additions & 0 deletions tests/test_protoc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def test_protoc_plugin(self):
proto_file_dir = os.path.dirname(proto_file.name)
proto_file_name = os.path.basename(proto_file.name)

os.environ["OPENTELEMETRY_PROTO_DIR"] = proto_file_dir

# Run protoc with custom plugin to generate serialization code for messages
result = subprocess.run([
"python",
Expand Down

0 comments on commit fb3c5c3

Please sign in to comment.