Skip to main content

AqueryContext

The context for performing aquery operations in bxl. The functions offered on this ctx are the same behaviour as the query functions available within aquery command.

Query results are target_sets of action_query_nodes, which supports iteration, indexing, len(), set addition/subtraction, and equals().

AqueryContext.all_actions

def AqueryContext.all_actions(
targets: bxl.ConfiguredTargetNode | bxl.UnconfiguredTargetNode | configured_target_label | label | providers_label | str | target_label | target_set | target_set | target_set | target_set | list[bxl.ActionQueryNode | bxl.ConfiguredTargetNode | bxl.UnconfiguredTargetNode | configured_target_label | label | providers_label | str | target_label],
) -> target_set

Obtain all the actions declared within the analysis of a given target.

This operation only makes sense on a target literal (it is a simple passthrough when passed an action).


AqueryContext.all_outputs

def AqueryContext.all_outputs(
targets: bxl.ConfiguredTargetNode | bxl.UnconfiguredTargetNode | configured_target_label | label | providers_label | str | target_label | target_set | target_set | target_set | target_set | list[bxl.ActionQueryNode | bxl.ConfiguredTargetNode | bxl.UnconfiguredTargetNode | configured_target_label | label | providers_label | str | target_label],
) -> target_set

Obtain the actions for all the outputs provided by the DefaultInfo for the targets passed as input. This includes both the default_outputs and other_outputs.

This operation only makes sense on a target literal (it does nothing if passed something else).


AqueryContext.attrfilter

def AqueryContext.attrfilter(
attr: str,
value: str,
targets: bxl.ConfiguredTargetNode | bxl.UnconfiguredTargetNode | configured_target_label | label | providers_label | str | target_label | target_set | target_set | target_set | target_set | list[bxl.ActionQueryNode | bxl.ConfiguredTargetNode | bxl.UnconfiguredTargetNode | configured_target_label | label | providers_label | str | target_label],
) -> target_set

The attrfilter query for rule attribute filtering.


AqueryContext.deps

def AqueryContext.deps(
universe: bxl.ConfiguredTargetNode | bxl.UnconfiguredTargetNode | configured_target_label | label | providers_label | str | target_label | target_set | target_set | target_set | target_set | list[bxl.ActionQueryNode | bxl.ConfiguredTargetNode | bxl.UnconfiguredTargetNode | configured_target_label | label | providers_label | str | target_label],
depth: None | int = None,
filter: None | str = None,
) -> target_set

The deps query for finding the transitive closure of dependencies.


AqueryContext.eval

def AqueryContext.eval(
query: str,
query_args: None | target_set | list[str] = None,
)

Evaluates some general query string. query_args can be a target_set of unconfigured nodes, or a list of strings. Returns a dict of target labels mapped to their target_set results if query_args was passed in, otherwise returns a single target_set.

Sample usage:

def _impl_eval(ctx):
result = ctx.aquery().eval(":foo")
ctx.output.print(result)