Upgrade Transformers to resolve six Dependabot alerts#2189
Closed
SharonHart wants to merge 1 commit into
Closed
Conversation
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
Contributor
Contributor
Coverage report (presidio-anonymizer)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||
Contributor
Coverage report (presidio-image-redactor)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
Contributor
Coverage report (presidio-cli)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
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.lockaccordingly (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 intodoc.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, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
spacy-huggingface-pipelinesadapter, which caps Transformers below 5.0, with an internal spaCy token-classification bridgeSecurity impact
This resolves the next-largest Dependabot group: six open Transformers alerts across
pyproject.tomlanduv.lock(four high and two medium).Validation
poetry -C presidio-analyzer check --strictuv lock --checkwith uv 0.11.6