plain-carpet-73994
04/28/2021, 4:24 PMmy_target and generates some new files. As I understand it, I can return a custom`Goal` subclass that contains some information about those files but that does not generate new targets. Now suppose I want to make sure my generated code is safe via bandit. Since I don't have a new target and bandit 's @rule doesn't take a MyCustomGoal how do I tell bandit that it depends on (or should check) these custom files?hundreds-father-404
04/28/2021, 5:07 PMplain-carpet-73994
04/28/2021, 5:10 PMplain-carpet-73994
04/28/2021, 5:12 PMhundreds-father-404
04/28/2021, 5:13 PMplain-carpet-73994
04/28/2021, 5:14 PMA , that returns a Foo you can have another rule, B, that requests a Foo as input so when that goal B is requested Pants knows it need to run the rule A first.
What I don't understand is the more general case like bandit where it can't know what generated files might exist beforehand. If I generate a file how can I "talk about it" in other targets and rules?plain-carpet-73994
04/28/2021, 5:15 PMhundreds-father-404
04/28/2021, 5:16 PMrules don't output targets but they do generate filesTo clarify, rules can output whatever they want (as long as it's a single type with a hash and eq implementation). Rules can output targets, `Digest`s representing files, some custom type, etc
specify that output should be the input to another target or ruleYou either put that output type as an argument to your
@rule function, or use await Get(OutputType, OutputTypeRequest) in the calling rule. Which format you use depends on if Pants needs some input in order to compute OutputType vs. if it can be computed without extra input from the callsiteplain-carpet-73994
04/28/2021, 5:18 PMblob.foo file in some/dir and my custom rule generates a blob.py from that. If I want something else to depend on blob.py how do I refer to it? Can I put a some/dir/blob.py in the dependencies section of something like a package or bandit rule? I suspect not 'cause I don't think Pants wold know that file exits unless I specifically pants my_rule some/dir/blob.foo, right?hundreds-father-404
04/28/2021, 5:19 PMWhat I don't understand is the more general case like bandit where it can't know what generated files might exist beforehand.The caller needs to know about the output type so that it can request the output type There is a way to make that more generic through a thing called unions, which are polymorphism for the engine. This is how all of Pants's plugin hooks work - we have no idea what plugins users might right, but unions allow us to handle that. Although, most the time plugins don't need to set up their own unions because you are usually in total control of your pipeline https://www.pantsbuild.org/docs/rules-api-unions
plain-carpet-73994
04/28/2021, 5:19 PMhundreds-father-404
04/28/2021, 5:21 PMplain-carpet-73994
04/28/2021, 5:21 PMRules can output targetsThey can? I thought the pattern was:
class MyGoalSystem(GoalSubsystem):
# ...
class MyGoal(Goal):
# ...
@goal_rule
fun my_rule(...) -> MyGoal:
# ....
that is, I thought MyGoal had to be a subclass of Goal and my @goal_rule had to return that.hundreds-father-404
04/28/2021, 5:23 PMGoalplain-carpet-73994
04/28/2021, 5:23 PMplain-carpet-73994
04/28/2021, 5:24 PMhundreds-father-404
04/28/2021, 5:25 PMplain-carpet-73994
04/28/2021, 5:35 PM