hundreds-father-404
05/21/2020, 8:31 PMhundreds-father-404
05/21/2020, 8:31 PMwitty-crayon-22786
05/21/2020, 8:35 PMhundreds-father-404
05/21/2020, 8:43 PMDependencies
field to signal which dep inference implementation to use? E.g. PythonDependencies
and subclasses -> the Python rule that knows how to analyze Python code.
We would enforce that there is only one dep inference implementation for that type to avoid ambiguity, like we do with codegen.
As opposed to, for example, finding the corresponding Sources
field for the target and seeing if its PythonSources
.hundreds-father-404
05/21/2020, 8:44 PMresolve_dependencies
rule:
provided = field.raw_value
injected = result of running all injection rules for this Dependencies field type, like `ProtobufDependencies` having one
inferred = result of running the one single inferrer rule for this `Dependencies` field type, if any
return [*provided, *injected, *inferred]
witty-crayon-22786
05/21/2020, 8:46 PMDo you think it’s acceptable to use the identity of theyes, in general i do. i’d go further and say that each concrete class should require its own rule so that it’s an exact type match (but that’s the other conversation, heh.)field to signal which dep inference implementation to use? E.g.Dependencies
and subclasses -> the Python rule that knows how to analyze Python code.PythonDependencies
hundreds-father-404
05/21/2020, 8:47 PMwitty-crayon-22786
05/21/2020, 8:47 PMSources
, to compute the outputwitty-crayon-22786
05/21/2020, 8:47 PMwitty-crayon-22786
05/21/2020, 8:48 PMhundreds-father-404
05/21/2020, 8:48 PMDependencies
field to the inference rule. This field stores the address
, so, in the rule, we can call await Get[Target](Address, field.address)
hundreds-father-404
05/21/2020, 8:49 PMpresumably without requesting codegenAgreed. This current design wouldn’t do that because it would encounter a
protobuf_library
and see “I don’t have a inference rule for ProtobubLibrary; skip.”witty-crayon-22786
05/21/2020, 8:50 PMwitty-crayon-22786
05/21/2020, 8:50 PMwitty-crayon-22786
05/21/2020, 8:50 PMhundreds-father-404
05/21/2020, 8:53 PMi mean the dep inference ruleAs do I, but I think we’re on the same page here.
hundreds-father-404
05/21/2020, 8:53 PMwitty-crayon-22786
05/21/2020, 8:54 PMAgreed. This current design wouldn’t do that because it would encounter awhat i meant here is that while inferring deps, a rule for PythonDependencies would request PythonSources for the Sources field, which might trigger codegen otherwiseand see “I don’t have a inference rule for ProtobubLibrary; skip.”protobuf_library
hundreds-father-404
05/21/2020, 8:55 PMwhat i meant here is that while inferring deps, a rule for PythonDependencies would request PythonSources for the Sources field, which might trigger codegen otherwiseThis would only happen if in that rule we said
HydrateSourcesRequest(codegen_enabled=True)
. That is off by default.witty-crayon-22786
05/21/2020, 8:56 PMPythonDependencies + RustSources
hundreds-father-404
05/21/2020, 8:56 PMfor_sources_types=[PythonSources], codegen_enabled=False
witty-crayon-22786
05/21/2020, 8:57 PMwitty-crayon-22786
05/21/2020, 8:57 PMhundreds-father-404
05/21/2020, 8:57 PMsome arbitrary combination of fields where someone declared something like PythonDependencies + RustSourcesYay Field-Driven API? 🙃 hehe
witty-crayon-22786
05/21/2020, 8:58 PMwitty-crayon-22786
05/21/2020, 8:58 PMwitty-crayon-22786
05/21/2020, 8:59 PMhundreds-father-404
05/21/2020, 9:00 PMit does make me wonder whether this should really be kicked off by dependencies subclasses rather than sources** subclassesI don’t follow
witty-crayon-22786
05/21/2020, 9:03 PMwitty-crayon-22786
05/21/2020, 9:03 PMhundreds-father-404
05/21/2020, 9:05 PMSources
field’s identity is.
We could make this work without making call sites more complex, I think (one of my main goals).
In resolve_dependencies
, call await Get[WrappedTarget](Address, deps_field.address)
, then inspect the identity of the Sources
field, if any.witty-crayon-22786
05/21/2020, 9:08 PMwitty-crayon-22786
05/21/2020, 9:08 PMhundreds-father-404
05/21/2020, 9:09 PMawait Get[WrappedTarget]
so that we base this in the Sources
identity is much more complex. (I thought it would be way more involved when I started this thread)witty-crayon-22786
05/21/2020, 9:09 PMwitty-crayon-22786
05/21/2020, 9:10 PMwitty-crayon-22786
05/21/2020, 9:10 PMhundreds-father-404
05/21/2020, 9:12 PMi do idly wonder whether some of these things would be easier if they operated on batches of fieldsthe
AsyncField
PR confirmed my intuition that I don’t think so. Most those call sites resolved dependencies in very different stages than hydrating sources. Some, like setup-py
, never even need sourceshundreds-father-404
05/21/2020, 9:13 PMwitty-crayon-22786
05/21/2020, 9:36 PMhundreds-father-404
05/21/2020, 9:36 PMawait Get[WrappedTarget]
in resolve_dependencies
is an unnecessary perf hit if you don’t even have dep inference.
While small, there is a cost to go from Address -> Target
, such as calling the constructor for every Field
registered on the target.
Two ways to solve this, I think:
1. Add a global flag --dependency-inference-enabled
2. Simply check the UnionMembership
to see if there are any implementations registered in the first place.
I think #2 is better, right? Simpler and easier to onboard folks.witty-crayon-22786
05/21/2020, 9:38 PMwitty-crayon-22786
05/21/2020, 9:38 PMwitty-crayon-22786
05/21/2020, 9:39 PMwitty-crayon-22786
05/21/2020, 9:39 PMhundreds-father-404
05/21/2020, 9:40 PMwitty-crayon-22786
05/21/2020, 9:41 PM