Skip to content

MAINT: Evict I/O modules from pyrit.models into pyrit.memory.storage#1929

Merged
rlundeen2 merged 13 commits into
microsoft:mainfrom
rlundeen2:rlundeen2/evict-io-to-pyrit-io
Jun 6, 2026
Merged

MAINT: Evict I/O modules from pyrit.models into pyrit.memory.storage#1929
rlundeen2 merged 13 commits into
microsoft:mainfrom
rlundeen2:rlundeen2/evict-io-to-pyrit-io

Conversation

@rlundeen2
Copy link
Copy Markdown
Contributor

@rlundeen2 rlundeen2 commented Jun 4, 2026

Move StorageIO/DiskStorageIO/AzureBlobStorageIO, the data-type serializers, and data_serializer_factory out of pyrit.models into a new pyrit.io package. Leave deprecation shims (removed_in 0.17.0) at the old pyrit.models locations and method-level shims (Seed.set_sha256_value_async, MessagePiece.set_sha256_values_async) that delegate to the new free functions in pyrit.memory.storage.

Phase 9 of pyrit.models refactor here: https://gist.github.com/rlundeen2/3e8daa8e12a11b4b6e52587b3c9b1dca

Move StorageIO/DiskStorageIO/AzureBlobStorageIO, the data-type serializers, and data_serializer_factory out of pyrit.models into a new pyrit.io package. Leave deprecation shims (removed_in 0.17.0) at the old pyrit.models locations and method-level shims (Seed.set_sha256_value_async, MessagePiece.set_sha256_values_async) that delegate to the new free functions in pyrit.io.serializers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread pyrit/io/__init__.py Outdated
rlundeen2 and others added 2 commits June 4, 2026 12:37
Relocate the storage/serialization layer from the top-level pyrit.io package into pyrit.memory.storage, resolving the naming collision with pyrit.output and reflecting that the serializers are a facade over CentralMemory (results_path / results_storage_io). Updates all importers, deprecation shims, and the import-boundary allowlist.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rlundeen2 rlundeen2 changed the title MAINT: Evict I/O modules from pyrit.models into pyrit.io MAINT: Evict I/O modules from pyrit.models into pyrit.memory.storage Jun 4, 2026
Re-export the storage IO classes and data-type serializers from the pyrit.memory package root so callers can use the shorthand (e.g. 'from pyrit.memory import AzureBlobStorageIO'). Update all external consumers to the shorthand. Internal pyrit.memory.* modules keep importing from pyrit.memory.storage directly to avoid an import cycle during package init, and the pyrit.common foundation-layer files keep the precise submodule import.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread pyrit/common/data_url_converter.py Outdated
Comment thread pyrit/common/display_response.py Outdated
Comment thread pyrit/datasets/seed_datasets/remote/msts_dataset.py
Comment thread pyrit/message_normalizer/chat_message_normalizer.py
Comment thread pyrit/message_normalizer/chat_message_normalizer.py Outdated
Comment thread pyrit/models/__init__.py
Comment thread pyrit/prompt_converter/pdf_converter.py
Comment thread pyrit/prompt_target/openai/openai_chat_target.py
@romanlutz romanlutz self-assigned this Jun 4, 2026
rlundeen2 and others added 9 commits June 5, 2026 13:13
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
…-pyrit-io

# Conflicts:
#	pyrit/models/data_type_serializer.py
#	tests/unit/memory/storage/test_serializers.py
…or cycles

- display_response: consolidate to single 'from pyrit.memory import' shorthand
- chat_message_normalizer/openai_chat_target: revert cycle-inducing
  package-root self-imports to direct submodule imports
- test_import_boundary: update KNOWN_COMMON_VIOLATIONS allowlist to match
  shortened pyrit.memory imports

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

# Conflicts:
#	pyrit/models/data_type_serializer.py
#	pyrit/models/storage_io.py
- Apply ruff UP007/UP045 (Optional/Union -> X | None) to the relocated
  serializers.py and storage.py to match the repo-wide modernization
  (origin/main microsoft#1884)
- Add ty pragma for azure readall() str|bytes stub mismatch surfaced by
  the post-merge ty hardening (microsoft#1931)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These 6 type errors are pre-existing on main (third-party stub and
SQLAlchemy Base typing mismatches from the recent dep audit, microsoft#1931).
They were ungated on main because that PR did not touch these files;
relocating their imports to pyrit.memory newly subjects them to the
per-file ty gate. Add minimal pragmas consistent with the existing
codebase convention:
- sqlite_memory/azure_sql_memory: session.get(type(entry), entry.id)
- sqlite_memory: MemoryExporter.export_data(list(data), ...)
- add_image_text_converter: ImageFont.truetype(str | None, ...)
- openai_tts_target: AsyncSpeech.create response_format/speed
- azure_content_filter_scorer: ContentSafetyClient credential

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rlundeen2 rlundeen2 enabled auto-merge June 5, 2026 23:41
@rlundeen2 rlundeen2 added this pull request to the merge queue Jun 5, 2026
Merged via the queue into microsoft:main with commit 6fd1f6b Jun 6, 2026
53 checks passed
@rlundeen2 rlundeen2 deleted the rlundeen2/evict-io-to-pyrit-io branch June 6, 2026 00:00
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.

2 participants