-
Notifications
You must be signed in to change notification settings - Fork 785
MAINT: Minor pyrit.model module reorganization #1999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,6 @@ | |
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from pyrit.common.deprecation import print_deprecation_message | ||
| from pyrit.models.chat_message import ( | ||
| ALLOWED_CHAT_MESSAGE_ROLES, | ||
| ChatMessage, | ||
| ChatMessagesDataset, | ||
| ) | ||
| from pyrit.models.conversation_reference import ConversationReference, ConversationType | ||
| from pyrit.models.conversation_stats import ConversationStats | ||
| from pyrit.models.embeddings import EmbeddingData, EmbeddingResponse, EmbeddingSupport, EmbeddingUsageInformation | ||
| from pyrit.models.harm_definition import HarmDefinition, ScaleDescription, get_all_harm_definitions | ||
|
|
@@ -79,11 +73,18 @@ | |
| group_message_pieces_into_conversations, | ||
| sort_message_pieces, | ||
| ) | ||
| from pyrit.models.messages.chat_message import ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a back-compat shim at every old path?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rich agrees with this comment but it is copilot generated: Good catch on the inconsistency. Rather than add three more shims, we removed the deep-path shims altogether — including the four existing silent ones ( |
||
| ALLOWED_CHAT_MESSAGE_ROLES, | ||
| ChatMessage, | ||
| ChatMessagesDataset, | ||
| ToolCall, | ||
| ) | ||
| from pyrit.models.messages.conversation_reference import ConversationReference, ConversationType | ||
| from pyrit.models.question_answering import QuestionAnsweringDataset, QuestionAnsweringEntry, QuestionChoice | ||
| from pyrit.models.results.attack_result import AttackOutcome, AttackResult, AttackResultT | ||
| from pyrit.models.results.scenario_result import ScenarioIdentifier, ScenarioResult, ScenarioRunState | ||
| from pyrit.models.results.strategy_result import StrategyResult, StrategyResultT | ||
| from pyrit.models.retry_event import RetryEvent | ||
| from pyrit.models.scenario_result import ScenarioIdentifier, ScenarioResult, ScenarioRunState | ||
| from pyrit.models.score import Score, ScoreType, UnvalidatedScore | ||
|
|
||
| # Seeds - import from new seeds submodule for forward compatibility | ||
|
|
@@ -192,6 +193,7 @@ | |
| "TARGET_EVAL_PARAM_FALLBACKS", | ||
| "TARGET_EVAL_PARAMS", | ||
| "TextDataTypeSerializer", | ||
| "ToolCall", | ||
| "UnvalidatedScore", | ||
| "validate_registry_name", | ||
| "VideoPathDataTypeSerializer", | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't we do something like
PyRIT/pyrit/models/__init__.py
Line 215 in c39db20
if not, we should at least label the PR as breaking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rich agrees with this comment but it is copilot generated: We went the other direction and removed the deep-path shims entirely instead of adding more. The rule we settled on: if a symbol only moves within
pyrit.modelsand is still re-exported from the package root, there's no shim —from pyrit.models import ScenarioRunState(and every other symbol) keeps working, and that's the only import form we support/document. Warning shims are reserved for symbols that actually leave the package (e.g. thepyrit.memory.storagemoves). For consistency I also deleted the older silent shims that were still lingering (attack_result,message,message_piece,strategy_result). The only thing that breaks is the uncanonical deep pathfrom pyrit.models.scenario_result import ..., which was never the documented import.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(it got messy having so many deprecated shims, and I think when the import mostly stays the same it's likely okay to just move it)