fix: NLTK data download during Docker builds - #311
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5eb1891f3a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Download standard NLTK data, to prevent unstructured from downloading packages at runtime | ||
| RUN python -m nltk.downloader -d /app/nltk_data punkt_tab averaged_perceptron_tagger averaged_perceptron_tagger_eng | ||
| ENV NLTK_DATA=/app/nltk_data | ||
| RUN python -m nltk.downloader --exit-on-error -d /app/nltk_data punkt_tab averaged_perceptron_tagger averaged_perceptron_tagger_eng |
There was a problem hiding this comment.
Make NLTK download failures fail the image build
When any NLTK package cannot be fetched or resolved, --exit-on-error does not make python -m nltk.downloader return a non-zero status; I checked the NLTK CLI source and this option only sets halt_on_error, then the main loop breaks on rv == False without calling sys.exit, so Docker will still continue and can publish an image missing the required data. Please wrap this in a Python one-liner that exits based on nltk.download(...) results or otherwise force a non-zero status; the same command is present in Dockerfile.lite.
Useful? React with 👍 / 👎.
Description
This PR fixes the Docker image build failure caused by NLTK 3.10.0 rejecting the temporary download path for
punkt_tab.The Dockerfiles already downloaded NLTK data at build time to avoid runtime downloads by
unstructured, butNLTK_DATAwas only set after the download command. With newer NLTK path validation,/app/nltk_datamust be registered before the downloader writes package files there.Changes
NLTK_DATA=/app/nltk_databefore runningnltk.downloader.--exit-on-errorso Docker builds fail cleanly instead of prompting interactively.DockerfileandDockerfile.lite.Validation
Dockerfile.lite:The build completed successfully and downloaded
punkt_tab,averaged_perceptron_tagger, andaveraged_perceptron_tagger_eng.Peter Rothlaender ginkgo.rothlaender@external.daimlertruck.com on behalf of Daimler Truck AG.
Provider & Legal Notice | Daimler Truck
Copyright (c) {2026} Daimler Truck AG