Skip to main content

AuditContext

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

AuditContext.cell

def AuditContext.cell(
aliases_to_resolve: list[str] | tuple[str, ...] = [],
*,
aliases: bool = False,
) -> dict[str, str]

Query information about the [cells] list in .buckconfig.

Takes the following parameters:

  • aliases_to_resolve - list of cell aliases to query. These aliases will be resolved in the root cell of the BXL script.
  • optional aliases flag - if enabled, and no explicit aliases are passed, will query for all aliases in the root cell of the BXL script.

Returns a dict of cell name to absolute path mappings.

Sample usage:

def _impl_audit_cell(ctx):
    result = ctx.audit().cell(aliases = True)
    ctx.output.print(result)

AuditContext.output

def AuditContext.output(
output_path: str,
target_platform: None | str | target_label = ...,
)

Returns either: - The action which created the buck-out path, if exists. - The unconfigured_target_label constructed from the buck-out path, if the configuration hashes do not match. - None, if the configuration hash of the buck-out path matches the one passed into this function, or the default target configuration, but no action could be found that generated the buck-out path.

Takes in an optional target platform, otherwise will use the default target platform.

Sample usage:

def _impl_audit_output(ctx):
    target_platform = "foo"
    result = ctx.audit().output("buck-out/v2/gen/fbcode/some_cfg_hash/path/to/__target__/artifact", target_platform)
    ctx.output.print(result)