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

Path requirements for importing .proto files conflicts with grpc #254

Closed
wilf-phasecraft opened this issue Aug 16, 2024 · 2 comments
Closed

Comments

@wilf-phasecraft
Copy link

I have several .proto under the following directory structure

- mylibrary
|-- foo.proto
|-- bar.proto

The bar.proto file imports foo.proto using

import "mylibrary/foo.proto";

And this works fine when using gRPC to build Python code. However, when using ProtoBuf.jl as follows, I get a LoadError

import ProtoBuf

src = "."
dest = "../julia"

paths = ["foo.proto", "bar.proto"]

mkpath(dest)
ProtoBuf.protojl(paths, src, dest)
julia> include("generate_julia.jl")
ERROR: LoadError: Could not find following imports: ["mylibrary/numeric.proto"] within ["/Users/wilfrid/Documents/Projects/proto-buffet/mylibrary/", "/Users/wilfrid/.julia/packages/ProtoBuf/uNPdY/src/"]

It works fine if I simply specify the import as

import "foo.proto";

But then the gRPC fails to build the Python code. Am I missing something here?

@wilf-phasecraft
Copy link
Author

wilf-phasecraft commented Aug 16, 2024

ERROR: LoadError: Could not find following imports: ["phasecraft/numeric.proto"] within ["/Users/wilfrid/Documents/Projects/proto-buffet/phasecraft/", "/Users/wilfrid/.julia/packages/ProtoBuf/uNPdY/src/"]
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] resolve_imports!(imported_paths::Set{String}, parsed_files::Dict{String, ProtoBuf.CodeGenerators.ResolvedProtoFile}, search_directories::Vector{String})
   @ ProtoBuf.CodeGenerators ~/.julia/packages/ProtoBuf/uNPdY/src/codegen/modules.jl:255
 [3] _protojl(relative_paths::Vector{String}, search_directories::String, output_directory::String, options::ProtoBuf.CodeGenerators.Options)
   @ ProtoBuf.CodeGenerators ~/.julia/packages/ProtoBuf/uNPdY/src/codegen/CodeGenerators.jl:166
 [4] #protojl#36
   @ ~/.julia/packages/ProtoBuf/uNPdY/src/codegen/CodeGenerators.jl:138 [inlined]
 [5] protojl(relative_paths::Vector{String}, search_directories::String, output_directory::String)
   @ ProtoBuf.CodeGenerators ~/.julia/packages/ProtoBuf/uNPdY/src/codegen/CodeGenerators.jl:126
 [6] top-level scope
   @ ~/Documents/Projects/proto-buffet/mylibrary/generate_julia.jl:10
 [7] include(fname::String)
   @ Base.MainInclude ./client.jl:489
 [8] top-level scope
   @ REPL[2]:1
in expression starting at /Users/wilfrid/Documents/Projects/proto-buffet/mylibrary/generate_julia.jl:10

@wilf-phasecraft
Copy link
Author

Fixed by simply adding the parent to the search directories

import ProtoBuf

src = [".", ".."]
dest = "../julia"

paths = ["foo.proto", "bar.proto"]

mkpath(dest)
ProtoBuf.protojl(paths, src, dest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant