Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 01:36

    thesamet on master

    remove unused sbt-site plugin (… (compare)

  • 01:36
    thesamet closed #1450
  • 01:28
    xuwei-k ready_for_review #1450
  • 01:00
    xuwei-k synchronize #1450
  • 00:47
    thesamet commented #1449
  • 00:43
    xuwei-k opened #1450
  • 00:15
    honicky opened #1449
  • Dec 03 16:03

    dependabot[bot] on npm_and_yarn

    (compare)

  • Dec 03 16:03

    thesamet on master

    Bump decode-uri-component from … (compare)

  • Dec 03 16:03
    thesamet closed #1446
  • Dec 03 16:02

    thesamet on master

    remove unused plugins and build… (compare)

  • Dec 03 16:02
    thesamet closed #1448
  • Dec 03 16:01

    thesamet on master

    Update scalatestplus-scalacheck… (compare)

  • Dec 03 16:01
    thesamet closed #1447
  • Dec 03 11:46
    xuwei-k opened #1448
  • Dec 03 11:32
    xuwei-k ready_for_review #1447
  • Dec 03 11:15
    xuwei-k opened #1447
  • Dec 03 09:55
    dependabot[bot] labeled #1446
  • Dec 03 09:55
    dependabot[bot] opened #1446
  • Dec 03 09:55

    dependabot[bot] on npm_and_yarn

    Bump decode-uri-component from … (compare)

Nadav Samet
@thesamet
Passing different metadata is done by creating new stubs. This is a lightweight operation since the same RPC channel can be shared by any number of stubs.
DevilOps
@Davitron

Hi all, i'm trying to run sbt clean protocGenerate on a macbook apple silicon M1. I get the following error

[error] lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.15.6/protoc-3.15.6-osx-aarch_64.exe: not found: https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.15.6/protoc-3.15.6-osx-aarch_64.exe

I have added PB.protocVersion := "3.17.3" to my build.sbt but it still fails. How do I fix this?

Nadav Samet
@thesamet
@Davitron One of the reasons I can think of is that you are in a multi-project build, and the setting is not applied in a specific sub-project.
Ilya
@squadgazzz

@squadgazzz ScalaPB doesn't have a way to generate services where metadata is passed as a parameter to every rpc call.

What kind of stubs do you mean?

@squadgazzz ScalaPB doesn't have a way to generate services where metadata is passed as a parameter to every rpc call.

and why did you say about different metadata? it's the same

Nadav Samet
@thesamet
Stubs are referring to the generated interface for clients. It looks like the intent of your question was to ask how to pass different metadata to different client calls. The way to do this is to create a client, and then:
client.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata))
Nadav Samet
@thesamet
@brenon.alexis:matrix.org Merged your PR for sparksql-scalapb. If you need this fixed for sparksql-scalapb 0.10.x, I created a new branch 0.10.x that can be used as a target for backporting the fix.
1 reply
Petar Karadzhov
@karadzhov
@thesamet I gave it a try and there weren't any problems so far. I will try to make an actual client and server out of it soon just to verify that it's fine also during runtime and let you know. Thank you once more!
Alexis BRENON
@brenon.alexis:matrix.org
[m]
Hi. Thanks for the merges.
Can I expect a v0.10.5 release soon? Do I need to perform any action?
Nadav Samet
@thesamet
@brenon.alexis:matrix.org I've just released 0.10.5.
Dave Kichler
@dkichler

Hi there, just recently attempted to update one of my projects from sbt 1.4.9 to 1.5.5 and am now unable to resolve the binary protoc-gen-validate dependencies:

[error] (client / update) lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] https://repo1.maven.org/maven2/io/envoyproxy/protoc-gen-validate/protoc-gen-validate/0.6.2/protoc-gen-validate-0.6.2-osx-x86_64.protoc-plugin: not found: https://repo1.maven.org/maven2/io/envoyproxy/protoc-gen-validate/protoc-gen-validate/0.6.2/protoc-gen-validate-0.6.2-osx-x86_64.protoc-plugin

it seems to be appending the wrong extension (.protoc-plugin vs .exe), the same dependency resolved via sbt 1.4.9:

sbt:project> show client/protobuf:managedClasspath
...
[info] * Attributed(/Users/dk/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/io/envoyproxy/protoc-gen-validate/protoc-gen-validate/0.6.2/protoc-gen-validate-0.6.2-osx-x86_64.exe)

Curious if anyone can explain the different extension? or suggest a workaround/fix

Nadav Samet
@thesamet
@dkichler can you file an issue with the exact steps to reproduce? A minimal example will be great.
Dave Kichler
@dkichler
Hi @thesamet - it turns out the issue only manifests in a cross-module dependency through .dependsOn(). I've put together this minimal example that reproduces the issue: https://github.com/dkichler/protoc-plugin-resolution-issue
Could very well be an sbt issue, but figured I'd start here in case anything pops out at you.
Dave Kichler
@dkichler
Happy to file an issue with more details if you think it belongs in one of the scalapb related repos
Nadav Samet
@thesamet
Thanks for providing the test repo @dkichler . I'll take a look soon. In the mean time, can you bump up the version of sbt to latest (1.5.5) and sbt-protoc to 1.0.4. It's possible that the bug you are seeing has been resolved upstream.
2 replies
Kyle Leeners
@kyle.leeners_gitlab
Hi there, looking for some guidance. We've got a proto file that is riddled with scalapb logic. We'd like to pull that file into a java service (through maven) and generate a java client. Currently the file does not contain any references to java. I'm wondering if the file can be imported and the java extra bits be tacked on? Things like java_outer_classname, java_package, etc. Are those even necessary?
Alternatively, I see grpc docs have native support for java generation. Any idea if the scala pb stuff will impact that generation? We have messages like so:
message Location {
    option (scalapb.message).no_box = true;
    string city = 1 [(scalapb.field).no_box = true];
    ...
}
Nadav Samet
@thesamet
Hi @kyle.leeners_gitlab , when you generate Java code from the proto, the scalapb options will not affect it, and setting java-specific options won't affect the Scala source generation.
Kyle Leeners
@kyle.leeners_gitlab
awesome, thanks! I'll start to go down that road
Kyle Leeners
@kyle.leeners_gitlab

Hello, another question. I've got a proto file that I'd like to generate as both scala and java. The file imports another proto file (sourced though sbt). I'm running into issues during the generation because the imported file doesn't have any of the java conversion options.

Is there a way to add / decorate the java conversion options? I don't have direct access to the file, only the ability to import it.

Here's the file i'm trying to pull in for reference

syntax = "proto3";

import "scalapb/scalapb.proto";

option (scalapb.options) = {
  single_file: true
  lenses: true
  retain_source_code_info: true
  flat_package: true
  no_default_values_in_constructor: true,
  package_name: "foo"
};

message PackageUid {
  option (scalapb.message).extends = "bar";
  option (scalapb.message).companion_extends = "baz";

  string uid = 1;
}
Nadav Samet
@thesamet
@kyle.leeners_gitlab you can use package-scoped options to enable java_conversions for an entire package: https://scalapb.github.io/docs/customizations/#package-scoped-options - the option to set is java_conversions: true
Kyle Leeners
@kyle.leeners_gitlab
i dont have the ability to define a package name for the PackageUid.proto. Is there some default that i can hook into? Or would it just be foo?
Nadav Samet
@thesamet
@kyle.leeners_gitlab The thing is that if you don't have package or java_package in that file, the generated Java code doesn't have a package statement. I can't recall the details, but this leads to a problem where the generated Java code can't be accessed from Scala, adn there isn't much that can be done on the ScalaPB side for this.
Kyle Leeners
@kyle.leeners_gitlab
okay good to know. Maybe I can bug some people to add a package statement
Nadav Samet
@thesamet
sounds like a pretty reasonable thing to have.
Nadav Samet
@thesamet
@dkichler I wasn't able to reproduce the plugin resolution either on Linux nor Mac. I think it's a local issue. However, there were a number of issues with the build itself. I sent a PR https://github.com/dkichler/protoc-plugin-resolution-issue/pull/1/files with various comments explaining the issues.
1 reply
Matt Davis
@Matt-S6
hi! Is this the right place to ask a scalapb-sparksql usage question? In particular I'm looking for a way to understand some scala implicit resolution on a GeneratedMessage.
Nadav Samet
@thesamet
Hi @Matt-S6 , yes, this is the best place for these questions! :)
Matt Davis
@Matt-S6
Yay! ok, @thesamet, I got the sparksql-scalapb-test project to reproduce the issue. Here's the draft PR: thesamet/sparksql-scalapb-test#5
1 reply
Nadav Samet
@thesamet
@Matt-S6 Yes, you're really close. The error message tells you that you need to provide an implicit Encoder for your type. In L118, try adding a second implicit parameter, encoder: org.apache.spark.sql.Encoder[A].
Another way to write it, since you don't need direct access to the implicit values and they are just being passed through:
def fromRawEventDS[A <: GeneratedMessage : GeneratedMessageCompanion : Encoder](
    ds: Dataset[RawEvent]
  ) = ...
7 replies
João Ferreira
@jtjeferreira
Hi. I am an happy user of scalapb. Thanks for this amazing project. However recently I had the need to use java grpc in another project and was really frustrated I could not find how to define custom types like in scalapb as described here https://scalapb.github.io/docs/customizations#custom-types. By luck, do you know if this a feature is available in Java? Or only scalapb implements this and it is not common in other languages? Or my google skills are failing me?
Nadav Samet
@thesamet
Hey @jtjeferreira , sorry have missed your question from last week - thanks for the feedback! Custom types is a unique feature of ScalaPB. The standard implementations do not offer this flexibility.
João Ferreira
@jtjeferreira
Thanks @thesamet
Vénérée Randrianarisoa
@Maia1003_gitlab

Hi everyone,
I am new to ScalaPB and started by using the tutorial by downloading the project from github: https://scalapb.github.io/docs/getting-started.

I managed to generate the codes after sbt compile in:
target/scala-2.13/src_managed/main/scalapb/com/example/tutorial/addressbook

My main question is how to use the generated codes (case classes for each message) obtained after compiling since they are in ..\target\scala-2.13\src_managed\main\scalapb\tutorial\addressbook\

Also, in the codes from github, there is no tutorial package in /scr/main/scala/: I tried to refactor and create a tutorial package as
\basic\src\main\scala\tutorial\AddressBookMain.scala but I got the same errors: Person and AddressBook are not found (cannot resolve symbol AddressBook and Person).

Coud someone help me with those please, I am really stuck with this (I use IntelliJ IDEA)
Thank you very much,
Best regards.
Maia

Nadav Samet
@thesamet
Hi @natevecc , can you try compiling and running your project in SBT outside IntelliJ? If this works, then try re-importing your project into IntelliJ. If it doesn't work, then let's look into the project structure.
Vénérée Randrianarisoa
@Maia1003_gitlab
The project structure is as follows: the generated codes are in C:\ScalaPBBasic\basic\target\scala-2.13\src_managed\main\scalapb\tutorial\addressbook
And yes it compiles outside of IntelliJ
Hi @thesamet : you are right, after following your advices, it works ! THANKS A LOT ! What is the problem with IntelliJ ?
Also I don't understand that codes in target folder can be used back in the scala main sources (new to Scala as well).
Nadav Samet
@thesamet
@Maia1003_gitlab , sometimes intellij doesn't detect when additional source directories get added to the projects, and then re-importing helps. Now that they are in, it should keep working.
ScalaPB generates sources under a different subdirectory (target/.../src-managed) so they don't get mixed up with your source code, and also so you don't edit them, or check them in source control.
SBT has a list of source directories to use, target/.../src_managed is one of them. If you type in sbt sourceDirectories it will print out this list.
Vénérée Randrianarisoa
@Maia1003_gitlab
@thesamet , thanks a lot !
Vénérée Randrianarisoa
@Maia1003_gitlab

Hi commnunity, I try to implement a server with ScalaPB by following this: https://medium.com/rahasak/reactive-microservices-with-grpc-and-scala-e4767ca2d34a. I got a red highligted error on build() , on server != null, and awaitTermination() is not recognized :val server = ServerBuilder
.forPort(9000)
.addService(ProtoReflectionService.newInstance())
.addService(DocumentServiceGrpc.bindService(new DocumentServiceImpl, ExecutionContext.global))
.build()
.start()

// block until shutdown
if (server != null) {
server.awaitTermination()
}

Have someone an up-to-date simple server example, please and see what is problem with this codes? Thank you. Best,
Nadav Samet
@thesamet
If you ignore the red highlight (potential IntelliJ bug), does it work in sbt?
Vénérée Randrianarisoa
@Maia1003_gitlab
@thesamet yes it is working with the red highlight as well (weird that it compiles without error)