https://pantsbuild.org/ logo
#development
Title
# development
b

bitter-ability-32190

06/02/2022, 2:50 PM
According to
InjectDependenciesRequest
you use the
Dependencies
field, but most target types just use the vanilla field, right? That means if I only care about
FortranDependencies
I can't tell the engine not to give me every
Dependencies
field, only the Fortran ones? Should we subclass
Dependencies
for each language to reduce the overhead of these requests? E.g.
fortan_source
stops using vanilla
Dependencies
and instead declares and uses
FortranDependencies
.
1
a

ancient-vegetable-10556

06/02/2022, 2:50 PM
This is a unions problem, right?
b

bitter-ability-32190

06/02/2022, 2:51 PM
I don't think so. I think it's just a declaration problem. As per the docstring:
Copy code
This will
    cause the class, and any subclass, to have the injection. Register this subclass with
    `UnionRule(InjectDependenciesRequest, InjectFortranDependencies)`, for example.
Really I'm being generic, but I'm pointing the finger at
python_sources
using
Dependencies
.
f

fast-nail-55400

06/02/2022, 2:56 PM
many of the other language backends already have specific subclasses when they need it, e.g.
ScalaDependenciesField
,
GoThirdPartyPackageDependenciesField
is the question rather whether we should have a standard set of
Dependencies
subclasses so out-of-tree plugins have a place to hook in?
b

bitter-ability-32190

06/02/2022, 2:58 PM
Oh yeah, I wasn't aware Python was an odd duck. I'll file an issue for us to audit and fix
a

ancient-vegetable-10556

06/02/2022, 2:58 PM
Every language implemented since Python was developed with a lot of hindsight
1
b

bitter-ability-32190

06/02/2022, 3:00 PM
Ah turns out I can't use
Inject...
because I need the evaluated Deps anyways
🤷‍♂️ I can get this via the provided address
Actually this brings up a good point. How can I inject dependencies using the set of dependencies without my injection as an input. I assume (and maybe I should try this) trying to request the dependencies in my injection rule would cause a rule cycle
I suppose in this case I can just make it an InferX rule, and then await the Python Infer flavor, knowing that will get cached when Pants engine also requests it
But that wont' handle other inferred/injected/explicit deps 😕
f

fast-nail-55400

06/02/2022, 4:19 PM
Is there a particular reason why your injection rule would need the current set of dependencies?
b

bitter-ability-32190

06/02/2022, 4:20 PM
Given an option I want to inject the GPU flavor of a module everywhere the CPU version is used
f

fast-nail-55400

06/02/2022, 4:21 PM
and those are represented by targets?
b

bitter-ability-32190

06/02/2022, 4:21 PM
So the user specifies
--foo-bar-use-gpu
and the dependencies on the CPU-bound
foo-bar
package are replaced with the GPU package. (Techincally all I can do is insert, not replace, see my recent issue but I have a workaround)
Specifically I want to replace
"3rdparty/python/deps:repository#mxnet"
with `"3rdparty/python/deps:repository#mxnet-cu102`"
(but in this case just adding it is sufficient)
In reality, I can probably assume that the explicit deps and the inferred deps from the built in rules is sufficient (as I contorl my own plugins). But I think this smells of a logic flaw 😕
f

fast-nail-55400

06/02/2022, 4:25 PM
or just the limits of the current abstraction
b

bitter-ability-32190

06/02/2022, 4:25 PM
yeah, thats a better phrase
OK confirmed its a rule graph cycle at least:
Copy code
Exception: The dependency graph contained a cycle: