get_action_metadata

get_action_metadata()

Access step-level metadata when authoring custom actions.

Get the metadata for the validation step where an action was triggered. This can be called by user functions to get the metadata for the current action.

Returns

: dict

A dictionary containing the metadata for the current step.

Examples

When creating a custom action, you can access the metadata for the current step using the get_action_metadata() function. Here’s an example of a custom action that logs the metadata for the current step:

import pointblank as pb

def log_issue():
    metadata = pb.get_action_metadata()
    print(f"Type: {metadata['type']}, Step: {metadata['step']}")

validation = (
    pb.Validate(
        data=pb.load_dataset(dataset="game_revenue", tbl_type="duckdb"),
        thresholds=pb.Thresholds(warning=0.05, error=0.10, critical=0.15),
        actions=pb.Actions(warning=log_issue),
    )
    .col_vals_regex(columns="player_id", pattern=r"[A-Z]{12}\d{3}")
    .col_vals_gt(columns="item_revenue", value=0.05)
    .col_vals_gt(
        columns="session_duration",
        value=15,
    )
    .interrogate()
)

validation
Type: col_vals_gt, Step: 2
Type: col_vals_gt, Step: 3
Pointblank Validation
2025-04-15|14:44:24
DuckDBWARNING0.05ERROR0.1CRITICAL0.15
STEP COLUMNS VALUES TBL EVAL UNITS PASS FAIL W E C EXT
#4CA64C 1
col_vals_regex
col_vals_regex()
player_id [A-Z]{12}\d{3} 2000 2000
1.00
0
0.00
#EBBC14 2
col_vals_gt
col_vals_gt()
item_revenue 0.05 2000 1701
0.85
299
0.15
#FF3300 3
col_vals_gt
col_vals_gt()
session_duration 15 2000 1675
0.84
325
0.16
2025-04-15 14:44:24 UTC< 1 s2025-04-15 14:44:24 UTC

Key pieces to note in the above example:

  • log_issue() (the custom action) collects metadata by calling get_action_metadata()
  • the metadata is a dictionary that is used to craft the log message
  • the action is passed as a bare function to the Actions object within the Validate object (placing it within Validate(actions=) ensures it’s set as an action for every validation step)