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

bazel-diff missing transitive modified external dependencies #184

Open
Louai-Abdelsalam opened this issue Jul 26, 2023 · 2 comments
Open

Comments

@Louai-Abdelsalam
Copy link

So I've run into a situation where bazel-diff isn't reflecting a change in an external repo down to an internal dependent rule.

The situation I have is a little complex however, so some context is warranted.

I have an internal rule (let's call it rule A) that depends on a target inside an external repo (let's call it repo B), which in turn actually depends on yet another external repo (let's call it repo C).
The thing to keep in mind however, is that I actually have control over repo C i.e I can modify repo C directly instead of the usual setup of transitive external dependencies being configured by the direct external dependency (i.e repo B configuring its own dependency on repo C).

Now, if I modify repo C, that actually doesn't trickle down to rule A, and so rule A is left "non-impacted" according to bazel-diff.

To "put a face to the name" so to speak, I am talking about a setup involving rules_python, where I reference a particular requirements.txt inside a pip_parse rule, which in turn when lazy loading will resolve an external repo for each of the python packages mentioned in its requirements.txt file, and those external repos representing the python packages are what I was referring to as repo A and repo B.

So to come full circle, I have a python test rule (i.e rule A) that is depending on one of the external repos housing a python package (i.e repo B), which in turn is depending on another external repo housing another python package (i.e repo C), and when I make modifications to repo C (through e.g modifying the version of package C in requirements.txt), that change doesn't trickle down to my python rule (i.e rule A), even though that's the behaviour I expect.

Now, I read on the documentation of the --fineGrainedHashExternalRepos flag that "By default, external repos are treated as an opaque blob", which I interpreted to mean that bazel-diff doesn't look through external repos (and so doesn't know what the transitive external deps really are). I interpreted it that way because actually using the --fineGrainedHashExternalRepos flag and giving it repo B seems to actually trickle the changes on repo C down to my rule A.
But that flag isn't really the answer to my problem, because it requires that I know in advance the names of the relevant external repos, which in order to know would require me to know my bazel-diff-impacted internal rules, which if I had known I wouldn't have needed bazel-diff in the first place. Also, giving that flag all external dependencies (i.e the return values of bazel query //external:*) isn't an option because then I run into a "too many args error" by bazel, which is expected, though honestly even without that error the bazel-diff run with so many fine-grained external repos would probably be very expensive.

So my question really boils down to: What are my options here? is this perhaps a feature request? If I had to guess, this problem will be reported more often in the near future because the setup rules_python uses seems to be what other external bazel repos that support lazy loading are converging onto (e.g rules_js as far as I can tell, though I'm less certain of that one).

In the time being I opted for a solution that uses the --seed-filepaths flag where I give it a file that has all the paths of all the files that configure external language dependencies (i.e requirements.txts for the cases of python, but a bunch of others too for the other languages in our monorepo), but it's an ugly solution because 1) I have to partially hardcode these paths on the seedfile, and 2) because that ends marking all our internal targets as impacted, which leads to us basically "building the world". It's still an acceptable solution though because external language dependencies aren't updated too often, and because our monorepo is still relatively small (and so building the world isn't yet a god-tier task), but of course if there's something better out there then I'd like to know.

If it helps, I made this repro repo (with instructions on the README) in case it's needed:
https://github.com/Louai-Abdelsalam/repro--Tinder.bazel-diff
rule A is //project:treadmill_tests, package B in this case is moto, and package C is cryptography.

Thanks in advance.

p.s in case it's relevant, I'm not using bzlmod.

@alexeagle
Copy link
Contributor

I think this is #134 where it was described as "expected behavior"

@tinder-maxwellelliott
Copy link
Collaborator

We use the --seed-filepaths and it has worked well enough for us. If you have a proposal on how to accomplish this transitive logic I would more than welcome it.

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

3 participants