witty-crayon-22786
05/21/2020, 1:00 AM@rule
to produce Addresses? … ie should that be the union here…?hundreds-father-404
05/21/2020, 1:04 AMPythonBinarySources
vs. PythonTestsSources
* override the alias
* override the docstringwitty-crayon-22786
05/21/2020, 1:06 AMDependencies
would be a @union
witty-crayon-22786
05/21/2020, 1:06 AMAddresses
for members of that unionwitty-crayon-22786
05/21/2020, 1:06 AMawait Get[Addresses](Dependencies, tgt[Dependencies])
witty-crayon-22786
05/21/2020, 1:07 AMAddresses
hundreds-father-404
05/21/2020, 1:14 AMfor each distinct member of the union, would require a rule to compute AddressesThat is something I am trying very actively to avoid. Like with hydration of sources, we don’t want every subclass to need to implement its own rule. Hydrating sources + hydrating dependencies are standard mechanisms, unlike, say how to implement a particular code generator. Instead, the `AsyncField`s expose hooks to add functionality. For example,
Sources
has a validate_snapshot
method that will get called in the single rule, which allows subclasses to add validation.
For Dependencies
, we will have a hook to inject new dependencies.
--
This is really important to get dep inference working correctly. We want that logic centralized into one rule and make it impossible for plugin authors to accidentally mess things up.
We also want to avoid plugin authors from ever needing to write a rule for how to hydrate their field, unless they for some reason have a custom AsyncField
. The Target API is meant to be a simple declarative interface for plugin authors.witty-crayon-22786
05/21/2020, 1:17 AMwitty-crayon-22786
05/21/2020, 1:18 AMwitty-crayon-22786
05/21/2020, 1:18 AMwitty-crayon-22786
05/21/2020, 1:19 AMhundreds-father-404
05/21/2020, 1:19 AMsorry, still spitballing (almost done, heh):Hehe that’s okay. It took me a long time to figure out things like the above. And I think it took me a couple PRs to get right. Also worth stress testing this, as an integral API
hundreds-father-404
05/21/2020, 1:21 AMis it possible that fields themselves should mostly not be subclassed, and instead some sort of field validator would be subclassed…?I don’t think so. See https://pantsbuild.slack.com/archives/C0D7TNJHL/p1590023083367900?thread_ts=1590022825.366400&cid=C0D7TNJHL The sentinel thing is an important use case, for example. That’s how in a Field-driven API we have rules signal what targets they are compatible with. For example,
pytest_runner.py
doesn’t say it needs PythonTests
target, it only needs PythonTestsSources
.witty-crayon-22786
05/21/2020, 1:24 AMThat’s how in a Field-driven API we have rules signal what targets they are compatible with.sortof… we don’t actually use the output type. we just match it
witty-crayon-22786
05/21/2020, 1:25 AMhundreds-father-404
05/21/2020, 1:27 AMDependencies
being an AsyncField
working, and now just need to fix some tests 😎 call sites aren’t actually much more boiler-platey!
And this should be all we ever have to do for the call sites to work with codegen synthetic deps + dep inference! (Unless we care about precise dependencies for codegen)