pyrit.models.ScenarioResult#
- class ScenarioResult(*, scenario_identifier: ScenarioIdentifier, objective_target_identifier: Dict[str, Any] | TargetIdentifier, attack_results: dict[str, List[AttackResult]], objective_scorer_identifier: Dict[str, Any] | ScorerIdentifier, scenario_run_state: Literal['CREATED', 'IN_PROGRESS', 'COMPLETED', 'FAILED'] = 'CREATED', labels: dict[str, str] | None = None, completion_time: datetime | None = None, number_tries: int = 0, id: UUID | None = None, objective_scorer: Scorer | None = None)[source]#
Bases:
objectScenario result class for aggregating scenario results.
- __init__(*, scenario_identifier: ScenarioIdentifier, objective_target_identifier: Dict[str, Any] | TargetIdentifier, attack_results: dict[str, List[AttackResult]], objective_scorer_identifier: Dict[str, Any] | ScorerIdentifier, scenario_run_state: Literal['CREATED', 'IN_PROGRESS', 'COMPLETED', 'FAILED'] = 'CREATED', labels: dict[str, str] | None = None, completion_time: datetime | None = None, number_tries: int = 0, id: UUID | None = None, objective_scorer: Scorer | None = None) None[source]#
Methods
__init__(*, scenario_identifier, ...[, ...])get_objectives(*[, atomic_attack_name])Get the list of unique objectives for this scenario.
Get the evaluation metrics for the scenario's scorer from the scorer evaluation registry.
Get the list of strategies used in this scenario.
normalize_scenario_name(scenario_name)Normalize a scenario name to match the stored class name format.
objective_achieved_rate(*[, atomic_attack_name])Get the success rate of this scenario.
- get_objectives(*, atomic_attack_name: str | None = None) List[str][source]#
Get the list of unique objectives for this scenario.
- get_scorer_evaluation_metrics() ScorerMetrics | None[source]#
Get the evaluation metrics for the scenario’s scorer from the scorer evaluation registry.
- Returns:
The evaluation metrics object, or None if not found.
- Return type:
- static normalize_scenario_name(scenario_name: str) str[source]#
Normalize a scenario name to match the stored class name format.
Converts CLI-style snake_case names (e.g., “foundry” or “content_harms”) to PascalCase class names (e.g., “Foundry” or “ContentHarms”) for database queries. If the input is already in PascalCase or doesn’t match the snake_case pattern, it is returned unchanged.
This is the inverse of ScenarioRegistry._class_name_to_scenario_name().
- Parameters:
scenario_name – The scenario name to normalize.
- Returns:
The normalized scenario name suitable for database queries.