Skip to content

MAINT Breaking: Convert ScenarioResult to Pydantic#1908

Merged
ValbuenaVC merged 6 commits into
microsoft:mainfrom
rlundeen2:rlundeen2/phase-7-scenario-result-pydantic
Jun 3, 2026
Merged

MAINT Breaking: Convert ScenarioResult to Pydantic#1908
ValbuenaVC merged 6 commits into
microsoft:mainfrom
rlundeen2:rlundeen2/phase-7-scenario-result-pydantic

Conversation

@rlundeen2
Copy link
Copy Markdown
Contributor

@rlundeen2 rlundeen2 commented Jun 3, 2026

This converts ScenarioResult to a Pydantic BaseModel. It is phase 7 of the pyrit.models refactor (and the last model move remaining!):

https://gist.github.com/rlundeen2/3e8daa8e12a11b4b6e52587b3c9b1dca

This one is breaking. I want to remove get_scorer_evaluation_metrics. There were no callers in our code, and it relies on scorer, so it's something we need to get rid of to make our dependency footprint small. Check out phase 9 where we'd want to evict this from pyrit.models to understand some of the annoying things about deprecation. But not a huge deal if we do want to keep as is.

rlundeen2 and others added 3 commits June 3, 2026 12:11
Relocate get_scorer_evaluation_metrics to pyrit.score.scenario_metrics.get_scenario_metrics, make display_group_map a public field, and keep to_dict/from_dict as deprecated shims preserving the legacy wire shape.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The helper had no production callers (the original ScenarioResult method
also had none), so relocating it in Phase 7 just moved dead code. Remove
the module, its test, and the pyrit.score export.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nario-result-pydantic

# Conflicts:
#	pyrit/models/scenario_result.py
#	tests/unit/models/test_import_boundary.py
Comment thread pyrit/models/scenario_result.py Outdated
Comment thread tests/unit/models/test_scenario_result.py Outdated
rlundeen2 and others added 3 commits June 3, 2026 12:43
- Convert ScenarioRunState from a Literal alias to a str-backed Enum
  (matches house style; backward-compatible at all string call sites).
- Move ScenarioResult.normalize_scenario_name to the end (static methods last).
- Guard ScoreEntry.__init__ against a None scorer_class_identifier and drop
  a now-unused type: ignore, fixing ty errors surfaced after merging origin/main.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…efault

- Move inline imports in test_scenario_result.py to the top of the file
- Simplify pyrit_version from default_factory to a plain default in
  ScenarioIdentifier and ComponentIdentifier (sibling identifiers)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ValbuenaVC ValbuenaVC enabled auto-merge June 3, 2026 21:05
@ValbuenaVC ValbuenaVC added this pull request to the merge queue Jun 3, 2026
Merged via the queue into microsoft:main with commit ed67a1a Jun 3, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants