Fix Docker container crash: pin transformers dependency and replace deprecated encode_plus#174
Conversation
…eprecated encode_plus The Docker builds using requirements-security.txt had transformers>=4.53.0 (unpinned upper bound), which pulled a newer incompatible version where BertTokenizer.encode_plus was removed. This caused all classification requests to fail with: "BertTokenizer has no attribute encode_plus" Changes: - Pin transformers==4.53.0 in requirements-security.txt (matches requirements.txt) - Add upper bounds to torch, huggingface-hub, safetensors, numpy, peft to prevent similar untested major version upgrades from breaking Docker builds - Replace all tokenizer.encode_plus() calls with tokenizer() across the codebase (the __call__ method is the modern, forward-compatible API that accepts identical parameters) Affected files: prediction_service.py, test_sms.py, stressTest_500.py, stressTest_1000_mlx.py, train_ots.py, train_ots_improved.py, compare_models.py, train_incremental.py, train_enhanced_multilingual.py https://claude.ai/code/session_018ERyTcyaXRpheHinYgiypJ
PR Review: Fix Docker container crash — transformers dependency & encode_plus deprecationOverall: Solid, well-scoped fix for a real production breakage. The root cause is correctly identified and addressed consistently across the codebase. What's done well
Minor concerns worth tracking1. Hard-pinning This prevents receiving security patches in any future 4.53.x release. Since this file is explicitly for security CVE mitigations, a range like 2.
3. Root cause: The underlying issue was that Test coverageExisting test files ( Summary
Good fix overall. The three items above are suggestions for follow-up, not blockers. Reviewed by Claude (claude-sonnet-4-6) |
The Docker builds using requirements-security.txt had transformers>=4.53.0 (unpinned
upper bound), which pulled a newer incompatible version where BertTokenizer.encode_plus
was removed. This caused all classification requests to fail with:
"BertTokenizer has no attribute encode_plus"
Changes:
similar untested major version upgrades from breaking Docker builds
(the call method is the modern, forward-compatible API that accepts identical
parameters)
Affected files: prediction_service.py, test_sms.py, stressTest_500.py,
stressTest_1000_mlx.py, train_ots.py, train_ots_improved.py, compare_models.py,
train_incremental.py, train_enhanced_multilingual.py