Description
Description of the problem / feature request:
Feature Request for directly specify the resoure requirement via resource_set
Feature requests: what underlying problem are you trying to solve with this feature?
resource_set
support for actions.run
and actions.run_shell
is added in d7f0724
However, per the comment #6477 (comment) #6477 (comment) and #6477 (comment). The API is not flexible enough.
Firstly, the callbale only receive a input_size
on calling-back. For example, rules_foreign_cc
can invoke underlying make
command, with the -j
option. The -j
option for make
command is not dependent on input_size
in any way. The rule author of rules_foreign_cc
can just use a magic number, say -j8
here. Or get the cpu count info from somewhere else. But the info cannot be determined from the input_size
in any means. And there are many more similar cases that the parallelism cannot be simply infered from input_size
Secondly, the API receive a callable, which is weird in Bazel, since Bazel is not designed around high order function at first.
Thirdly, the callable can only be top-level def
-ed function, which is very limited.
So it is suggested to simply accept a ResourceSetInfo
or dict at starlark api actions.run
and actions.run_shell
ctx.actions.run(
outputs = ...,
executable = ...,
resource_set = ResourceSetInfo(
cpu = 8,
memory = 512,
...,
),
)
And leave the responsibility of inferencing the number and constructing the ResourceSetInfo to the rule authors to maximize the rule authoring flexibility.