differential-privacy icon indicating copy to clipboard operation
differential-privacy copied to clipboard

[privacy-on-beam] bazel + gazelle import problems

Open bamnet opened this issue 4 years ago • 2 comments

As a Go developer, I expect to be able to take a working directory using go.mod and run commands like the following to generate a valid BUILD.bazel file and update my WORKSPACE to pull in the correct dependencies.

bazel run //:gazelle -- update-repos -from_file=go.mod
bazel run //:gazelle -- update .

When you try this with code that depends on pbeam, you get errors when you try to bazel build your code:

$ bazel build :pipeline
DEBUG: /home/bamnet/.cache/bazel/_bazel_bamnet/4e37c13c4fe56234ff0794b9b267f671/external/bazel_gazelle/internal/go_repository.bzl:184:18: com_github_apache_beam: gazelle: /home/bamnet/.cache/bazel/_bazel_bamnet/4e37c13c4fe56234ff0794b9b267f671/external/com_github_apache_beam/model/job-management/src/main/proto: directory contains multiple proto packages. Gazelle can only generate a proto_library for one package.
gazelle: /home/bamnet/.cache/bazel/_bazel_bamnet/4e37c13c4fe56234ff0794b9b267f671/external/com_github_apache_beam/runners/google-cloud-dataflow-java/worker/windmill/src/main/proto: directory contains multiple proto packages. Gazelle can only generate a proto_library for one package.
gazelle: /home/bamnet/.cache/bazel/_bazel_bamnet/4e37c13c4fe56234ff0794b9b267f671/external/com_github_apache_beam/sdks/java/extensions/protobuf/src/test/proto: directory contains multiple proto packages. Gazelle can only generate a proto_library for one package.
ERROR: /home/bamnet/.cache/bazel/_bazel_bamnet/4e37c13c4fe56234ff0794b9b267f671/external/com_github_google_differential_privacy_privacy_on_beam/pbeam/BUILD.bazel:23:11: no such package '@com_google_go_differential_privacy//noise': The repository '@com_google_go_differential_privacy' could not be resolved and referenced by '@com_github_google_differential_privacy_privacy_on_beam//pbeam:go_default_library'
ERROR: Analysis of target ':pipeline' failed; build aborted: Analysis failed
INFO: Elapsed time: 7.471s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (34 packages loaded, 26 targets configured)

I think the problem is the reference to "'@com_google_go_differential_privacy" specified in pbeam's bazel file, but am still investigating.

bamnet avatar Aug 18 '20 03:08 bamnet

As a workaround, users can rename the generated com_github_google_differential_privacy_go go_repository rule to com_google_go_differential_privacy.

This feels a bit clumsy though. Perhaps the internal WORKFLOW + BUILD + ??? should be updated to reflect the fact that this package is published at com_github_google_differential_privacy_go.

bamnet avatar Aug 18 '20 04:08 bamnet

Hey @bamnet ,

After a couple of iterations, I think the instructions for Bazel should do the trick. Could you please confirm if it works and looks good?

miracvbasaran avatar Aug 09 '21 13:08 miracvbasaran

I think this should be fixed by now. In the next push we will also add Bazel rules to upgrade the repos.

dibakch avatar Nov 09 '22 17:11 dibakch