Skip to content

Integrate data snapshot pipeline - #44

Merged
avsolatorio merged 8 commits into
worldbank:mainfrom
ajdajd:feat/data-snapshot-pipeline
Oct 23, 2026
Merged

avsolatorio merged 8 commits into
worldbank:mainfrom
ajdajd:feat/data-snapshot-pipeline

Conversation

@ajdajd

@ajdajd ajdajd commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Integrates the production Data Snapshot pipeline as ai4data.data_snapshot, separate from the research implementation under experimental/data-snapshot.

  • Supports end-to-end PDF processing, snapshot-only extraction, and metadata-only extraction.
  • Uses DocLayout-YOLO by default, with optional YOLO11, YOLO26, and TF-ID adapters.
  • Extracts validated Schema v1.4 metadata through OpenRouter or OpenAI.
  • Adds dependency extras, packaged prompts and provider presets, offline tests, and CI checks.

Documentation scope

Documentation is limited to repository READMEs covering installation, configuration, commands, outputs, and development.

Concepts, methods, worked examples, and user guides intended for the published site will be covered in a separate PR.

Installation and release

The new extras are absent from ai4data==0.1.0. The README documents installation from the checkout until a release containing this module is published. After publication, users can install:

pip install "ai4data[data-snapshot-doclayoutyolo,data-snapshot-metadata]"

Editable installation remains documented for development. TF-ID requires a separate environment because of its older model dependency stack.

Validation

  • 71 snapshot tests passed.
  • 85 adjacent regression tests passed during integration review.
  • Wheel and source distribution built successfully; packaged resources and installed execution were checked.
  • A manual end-to-end PDF run produced three snapshots and three metadata files.

Limitations

Submission remains a mock implementation. The full repository test suite and real inference for every optional adapter were not run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Images sharing a filename stem can silently lose metadata through skipped extraction or overwritten output.

1 open issue
What changed in this PR

Integrates a production Data Snapshot pipeline into ai4data, separate from the experimental research package.

Changes:

  • Adds PDF snapshot extraction with four detector adapters and stage-specific commands.
  • Adds Schema v1.4 metadata extraction through OpenRouter or OpenAI.
  • Adds installation extras, packaged resources, documentation, and offline CI tests.
File Description
tests/​data_snapshot/​test_yolo26.py Tests detection normalization and cached weights.
tests/​data_snapshot/​test_yolo11.py Tests YOLO11 defaults.
tests/​data_snapshot/​test_tfid.py Tests TF-ID detection and configuration.
tests/​data_snapshot/​test_submission.py Tests mock submission output.
tests/​data_snapshot/​test_pipeline.py Tests orchestration and output cleanup.
tests/​data_snapshot/​test_metadata_schema.py Tests schema examples and version.
tests/​data_snapshot/​test_metadata_extraction.py Tests metadata requests and failures.
tests/​data_snapshot/​test_metadata_batch.py Tests JSON writing and replacement.
tests/​data_snapshot/​test_installation.py Tests installed imports and resources.
tests/​data_snapshot/​test_foundation.py Tests discovery, rendering, and naming.
tests/​data_snapshot/​test_extraction.py Tests cropping and duplicate PDF rejection.
tests/​data_snapshot/​test_doclayoutyolo.py Tests default detector configuration.
tests/​data_snapshot/​test_detection.py Tests detection validation.
tests/​data_snapshot/​test_cli.py Tests command arguments and errors.
tests/​conftest.py Exempts snapshot tests from classifier mocking.
src/​ai4data/​data_snapshot/​submission.py Adds mock submission.
src/​ai4data/​data_snapshot/​rendering.py Renders PDF pages as RGB images.
src/​ai4data/​data_snapshot/​README.md Documents installation and usage.
src/​ai4data/​data_snapshot/​pipeline.py Coordinates extraction stages and reruns.
src/​ai4data/​data_snapshot/​naming.py Defines deterministic snapshot names.
src/​ai4data/​data_snapshot/​metadata_schema/​models.py Defines Schema v1.4 models and validation.
src/​ai4data/​data_snapshot/​metadata_schema/​__init__.py Exports schema models.
src/​ai4data/​data_snapshot/​metadata_extraction/​prompts/​user.md Defines field extraction guidance.
src/​ai4data/​data_snapshot/​metadata_extraction/​prompts/​system.md Defines image-only evidence boundaries.
src/​ai4data/​data_snapshot/​metadata_extraction/​extraction.py Implements metadata requests and validation.
src/​ai4data/​data_snapshot/​metadata_extraction/​config/​openrouter.json Adds OpenRouter settings.
src/​ai4data/​data_snapshot/​metadata_extraction/​config/​openai.json Adds OpenAI settings.
src/​ai4data/​data_snapshot/​metadata_extraction/​batch.py Writes metadata for image batches.
src/​ai4data/​data_snapshot/​metadata_extraction/​__init__.py Exports metadata extraction APIs.
src/​ai4data/​data_snapshot/​inputs.py Discovers PDFs and images recursively.
src/​ai4data/​data_snapshot/​extraction.py Detects, crops, and saves snapshots.
src/​ai4data/​data_snapshot/​extract_metadata.py Adds metadata-only entry point.
src/​ai4data/​data_snapshot/​extract_data_snapshot.py Adds snapshot-only entry point.
src/​ai4data/​data_snapshot/​detection.py Defines the detector contract.
src/​ai4data/​data_snapshot/​cli.py Implements stage-specific commands.
src/​ai4data/​data_snapshot/​adapters/​yolo26.py Adds YOLO26 inference and normalization.
src/​ai4data/​data_snapshot/​adapters/​yolo11.py Adds YOLO11 configuration.
src/​ai4data/​data_snapshot/​adapters/​tfid.py Adds pinned TF-ID inference.
src/​ai4data/​data_snapshot/​adapters/​doclayoutyolo.py Adds the default DocLayout-YOLO adapter.
src/​ai4data/​data_snapshot/​adapters/​__init__.py Selects detector adapters.
src/​ai4data/​data_snapshot/​__main__.py Adds end-to-end module execution.
src/​ai4data/​data_snapshot/​__init__.py Exposes lazy public APIs.
src/​ai4data/​__init__.py Exposes the snapshot namespace.
README.md Adds installation and usage links.
pyproject.toml Adds optional runtime dependencies.
experimental/​data-snapshot/​README.md Distinguishes research and production workflows.
.gitignore Ignores outputs and the TF-ID environment.
.github/​workflows/​data-snapshot.yml Builds distributions and runs offline tests.

Review effort: Balanced

Comment thread src/ai4data/data_snapshot/metadata_extraction/batch.py
ajdajd and others added 4 commits October 22, 2026 14:11
Add validation to ensure unique snapshot image filename stems.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ajdajd

ajdajd commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Fixed issues and merge conflicts. Updated the readmes to match the updated docs.

@avsolatorio for your review, please :)

@avsolatorio avsolatorio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, @ajdajd

Comment thread src/ai4data/data_snapshot/adapters/doclayoutyolo.py Outdated
Comment thread src/ai4data/data_snapshot/adapters/tfid.py Outdated
Comment thread src/ai4data/data_snapshot/adapters/yolo11.py Outdated
Comment thread src/ai4data/data_snapshot/adapters/yolo26.py Outdated
…iable overrides.

Precedence: explicit Python arguments → environment variables → JSON defaults
@ajdajd

ajdajd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@avsolatorio I moved the model defaults to a json file and implemented env variable overrides. The variable names are documented in the readme.

Precedence: explicit Python arguments → env variables → JSON defaults

@avsolatorio
avsolatorio merged commit de58192 into worldbank:main Oct 23, 2026
2 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