Skip to content

[DRAFT] FIX: Offload local dataset file reads - #2402

Draft
biefan (biefan) wants to merge 1 commit into
microsoft:mainfrom
biefan:agent/offload-local-dataset-io
Draft

[DRAFT] FIX: Offload local dataset file reads#2402
biefan (biefan) wants to merge 1 commit into
microsoft:mainfrom
biefan:agent/offload-local-dataset-io

Conversation

@biefan

Copy link
Copy Markdown
Contributor

Description

Local dataset loading currently performs synchronous file reads and YAML parsing from async methods. This can block the event loop while datasets are loaded or their metadata is discovered.

This change:

  • runs SeedDataset.from_yaml_file in a worker thread from fetch_dataset_async;
  • moves local metadata file reading and YAML parsing into the same non-blocking path; and
  • adds regression tests that verify the synchronous loaders are passed to asyncio.to_thread instead of being called on the event loop thread.

Dataset contents, metadata coercion, filtering, and error propagation remain unchanged.

Tests and Documentation

  • uv run pytest tests/unit/datasets/test_local_dataset_loader.py tests/unit/datasets/test_seed_dataset_provider.py -q — 210 passed
  • uv run ruff check pyrit/datasets/seed_datasets/local/local_dataset_loader.py tests/unit/datasets/test_local_dataset_loader.py tests/unit/datasets/test_seed_dataset_provider.py — passed
  • uv run ruff format --check pyrit/datasets/seed_datasets/local/local_dataset_loader.py tests/unit/datasets/test_local_dataset_loader.py tests/unit/datasets/test_seed_dataset_provider.py — passed
  • uv run ty check pyrit/datasets/seed_datasets/local/local_dataset_loader.py — passed

Documentation and JupyText updates are not applicable because this does not change the public API or documented behavior.

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.

1 participant