Skip to content

Upgrade Transformers to resolve six Dependabot alerts#2189

Closed
SharonHart wants to merge 1 commit into
mainfrom
fix-transformers-alerts
Closed

Upgrade Transformers to resolve six Dependabot alerts#2189
SharonHart wants to merge 1 commit into
mainfrom
fix-transformers-alerts

Conversation

@SharonHart

Copy link
Copy Markdown
Contributor

Summary

  • require Transformers 5.5.0 or newer in the analyzer Transformers and GLiNER extras
  • replace the incompatible spacy-huggingface-pipelines adapter, which caps Transformers below 5.0, with an internal spaCy token-classification bridge
  • refresh the analyzer lockfile to Transformers 5.6.2 and Hugging Face Hub 1.24.0

Security impact

This resolves the next-largest Dependabot group: six open Transformers alerts across pyproject.toml and uv.lock (four high and two medium).

Validation

  • poetry -C presidio-analyzer check --strict
  • uv lock --check with uv 0.11.6
  • targeted Ruff checks with the repository-pinned version
  • 8 focused Transformers NLP engine tests

Replace the incompatible spaCy adapter with an internal token-classification bridge.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2e86159d-80a9-4926-9378-c5dabe07a39f
Copilot AI review requested due to automatic review settings July 22, 2026 09:11
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (presidio-structured)

This PR does not seem to contain any modification to coverable code.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (presidio-anonymizer)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  presidio-anonymizer/presidio_anonymizer
  __init__.py
  anonymizer_engine.py
  presidio-anonymizer/presidio_anonymizer/operators
  custom.py
Project Total  

This report was generated by python-coverage-comment-action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (presidio-image-redactor)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  presidio-image-redactor/presidio_image_redactor
  dicom_image_pii_verify_engine.py
  document_intelligence_ocr.py
  image_analyzer_engine.py
Project Total  

This report was generated by python-coverage-comment-action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (presidio-cli)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  presidio-cli/presidio_cli
  cli.py
Project Total  

This report was generated by python-coverage-comment-action

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.

Pull request overview

This PR upgrades the Presidio Analyzer’s Transformers integration to address Dependabot alerts by moving to Transformers 5.5+ and replacing the spacy-huggingface-pipelines dependency with an internal spaCy token-classification bridge.

Changes:

  • Bump the analyzer’s Transformers-related dependency constraints (Transformers 5.5+; tighten GLiNER Transformers range) and refresh uv.lock accordingly (Transformers 5.6.2, Hugging Face Hub 1.24.0).
  • Replace the external spaCy↔Transformers adapter with an internal spaCy pipeline component (presidio_transformers_ner) which writes spans + scores into doc.spans.
  • Add focused unit tests for the new spaCy pipe behavior and update docs/links to reference Hugging Face pipeline documentation.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
presidio-analyzer/uv.lock Refresh lockfile for upgraded Transformers/HF Hub and remove spacy-huggingface-pipelines.
presidio-analyzer/tests/test_transformers_nlp_engine.py Add tests validating spans + score storage and batching behavior for the new spaCy pipe.
presidio-analyzer/pyproject.toml Raise Transformers minimum version and remove the incompatible adapter from extras.
presidio-analyzer/presidio_analyzer/predefined_recognizers/nlp_engine_recognizers/transformers_recognizer.py Update reference link from the removed adapter to the HF pipeline docs.
presidio-analyzer/presidio_analyzer/nlp_engine/transformers_nlp_engine.py Implement internal spaCy token-classification bridge and wire it into TransformersNlpEngine.
docs/analyzer/nlp_engines/transformers.md Update documentation link to Hugging Face token-classification pipeline parameters.

Comment on lines +53 to +58
pipeline_kwargs = {
"task": "token-classification",
"model": model,
"aggregation_strategy": aggregation_strategy,
"device": device_detector.get_device(),
}
Comment on lines +111 to +113
logger.warning(
"Skipping malformed Transformers prediction: %s", prediction
)
Comment on lines +123 to +126
logger.warning(
"Skipping unaligned or overlapping Transformers prediction: %s",
prediction,
)
@SharonHart SharonHart closed this Jul 22, 2026
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