-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api v1alpha1 #17
Open
guimou
wants to merge
22
commits into
DS4SD:main
Choose a base branch
from
guimou:api-upgrade
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
api v1alpha1 #17
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
528ca3a
api v1alpha1
guimou 1f17348
use actual types in request models and refactor
dolfim-ibm 32f358a
make gradio optional and update README
dolfim-ibm 04e2457
Run workflow jobs sequentially to avoid disk space outage (#19)
vishnoianil 930d3fd
Add github job to build image (and not publish) on PR creation (#20)
vishnoianil c3836ed
add start_server script for local dev
dolfim-ibm fda5862
fix 3.12-only syntax
dolfim-ibm 26c6ac4
fix more py3.10-11 compatibility
dolfim-ibm 5bedade
rework output format and background tasks
dolfim-ibm 26765ac
speficy return schemas for openapi
dolfim-ibm 6a5aa98
add processing time and update REDAME
dolfim-ibm 407d827
lint markdown
dolfim-ibm 8a09a10
add MD033 to config
dolfim-ibm 13e281e
Merge remote-tracking branch 'origin/main' into api-upgrade
dolfim-ibm bae6b71
use port 5000
dolfim-ibm de49a13
use port 5001 as default
dolfim-ibm 1bcfe7f
update deps
dolfim-ibm 2758bf6
refactor input request
dolfim-ibm ca47ef8
return docling document
dolfim-ibm c567a82
update new payload in README
dolfim-ibm 95f448d
add base64 example
dolfim-ibm c7f2601
wrap example in <details>
dolfim-ibm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Ignore Python cache files | ||
__pycache__/ | ||
**/__pycache__/ | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
|
||
# Ignore virtual environments | ||
env/ | ||
venv/ | ||
|
||
# Ignore development artifacts | ||
*.log | ||
*.db | ||
*.sqlite3 | ||
|
||
# Ignore configuration and sensitive files | ||
**/.env | ||
*.env | ||
*.ini | ||
*.cfg | ||
|
||
# Ignore IDE and editor settings | ||
.vscode/ | ||
.idea/ | ||
*.swp | ||
*.swo | ||
|
||
# Ignore Git files | ||
.git/ | ||
.gitignore | ||
|
||
# Ignore Docker files themselves (optional if not needed in the image) | ||
.dockerignore | ||
Dockerfile* | ||
|
||
# Ignore build artifacts (if applicable) | ||
build/ | ||
dist/ | ||
*.egg-info |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
name: Dry run docling-serve image building | ||
|
||
on: | ||
pull_request: | ||
branches: ["main"] | ||
|
||
env: | ||
GHCR_REGISTRY: ghcr.io | ||
GHCR_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu | ||
GHCR_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve | ||
|
||
jobs: | ||
build_cpu_image: | ||
name: Build docling-serve "CPU only" container image | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
attestations: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
|
||
- name: Extract metadata (tags, labels) for docling-serve (CPU only) ghcr image | ||
id: ghcr_serve_cpu_meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_CPU_IMAGE_NAME }} | ||
|
||
- name: Build docling-serve-cpu image | ||
id: build-serve-cpu-ghcr | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: false | ||
tags: ${{ steps.ghcr_serve_cpu_meta.outputs.tags }} | ||
labels: ${{ steps.ghcr_serve_cpu_meta.outputs.labels }} | ||
platforms: linux/amd64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
file: Containerfile | ||
build-args: | | ||
--build-arg CPU_ONLY=true | ||
|
||
- name: Remove Local Docker Images | ||
run: | | ||
docker image prune -af | ||
|
||
build_gpu_image: | ||
name: Build docling-serve (with GPU support) container image | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
attestations: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
|
||
- name: Extract metadata (tags, labels) for docling-serve (GPU) ghcr image | ||
id: ghcr_serve_gpu_meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_GPU_IMAGE_NAME }} | ||
|
||
- name: Build docling-serve (GPU) image | ||
id: build-serve-gpu-ghcr | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: false | ||
tags: ${{ steps.ghcr_serve_gpu_meta.outputs.tags }} | ||
labels: ${{ steps.ghcr_serve_gpu_meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
file: Containerfile | ||
build-args: | | ||
--build-arg CPU_ONLY=false |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,61 @@ | ||
FROM python:3.11-slim-bookworm | ||
ARG BASE_IMAGE=quay.io/sclorg/python-312-c9s:c9s | ||
|
||
FROM ${BASE_IMAGE} | ||
|
||
ARG CPU_ONLY=false | ||
WORKDIR /docling-serve | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y libgl1 libglib2.0-0 curl wget git \ | ||
&& apt-get clean | ||
USER 0 | ||
|
||
RUN pip install --no-cache-dir poetry | ||
################################################################################################### | ||
# OS Layer # | ||
################################################################################################### | ||
|
||
COPY pyproject.toml poetry.lock README.md /docling-serve/ | ||
RUN --mount=type=bind,source=os-packages.txt,target=/tmp/os-packages.txt \ | ||
dnf -y install --best --nodocs --setopt=install_weak_deps=False dnf-plugins-core && \ | ||
dnf config-manager --best --nodocs --setopt=install_weak_deps=False --save && \ | ||
dnf config-manager --enable crb && \ | ||
dnf -y update && \ | ||
dnf install -y $(cat /tmp/os-packages.txt) && \ | ||
dnf -y clean all && \ | ||
rm -rf /var/cache/dnf | ||
|
||
RUN if [ "$CPU_ONLY" = "true" ]; then \ | ||
poetry install --no-root --with cpu; \ | ||
else \ | ||
poetry install --no-root; \ | ||
fi | ||
ENV TESSDATA_PREFIX=/usr/share/tesseract/tessdata/ | ||
|
||
ENV HF_HOME=/tmp/ | ||
ENV TORCH_HOME=/tmp/ | ||
################################################################################################### | ||
# Docling layer # | ||
################################################################################################### | ||
|
||
RUN poetry run python -c 'from docling.pipeline.standard_pdf_pipeline import StandardPdfPipeline; artifacts_path = StandardPdfPipeline.download_models_hf(force=True);' | ||
USER 1001 | ||
|
||
WORKDIR /opt/app-root/src | ||
|
||
# On container environments, always set a thread budget to avoid undesired thread congestion. | ||
ENV OMP_NUM_THREADS=4 | ||
|
||
COPY ./docling_serve /docling-serve/docling_serve | ||
ENV LANG=en_US.UTF-8 | ||
ENV LC_ALL=en_US.UTF-8 | ||
ENV PYTHONIOENCODING=utf-8 | ||
|
||
ENV WITH_UI=True | ||
|
||
COPY --chown=1001:0 pyproject.toml poetry.lock models_download.py README.md ./ | ||
|
||
RUN pip install --no-cache-dir poetry && \ | ||
# We already are in a virtual environment, so we don't need to create a new one, only activate it. | ||
poetry config virtualenvs.create false && \ | ||
source /opt/app-root/bin/activate && \ | ||
if [ "$CPU_ONLY" = "true" ]; then \ | ||
poetry install --no-root --no-cache --no-interaction --all-extras --with cpu --without dev; \ | ||
else \ | ||
poetry install --no-root --no-cache --no-interaction --all-extras --without dev; \ | ||
fi && \ | ||
echo "Downloading models..." && \ | ||
python models_download.py && \ | ||
chown -R 1001:0 /opt/app-root/src && \ | ||
chmod -R g=u /opt/app-root/src | ||
|
||
COPY --chown=1001:0 --chmod=664 ./docling_serve ./docling_serve | ||
|
||
EXPOSE 5000 | ||
EXPOSE 8080 | ||
|
||
CMD ["poetry", "run", "uvicorn", "--port", "5000", "--host", "0.0.0.0", "docling_serve.app:app"] | ||
CMD ["python", "docling_serve/app.py"] |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any specific need to run this service on port 8080? I am wondering If we can revert it 5000 or some other non-80** port? @dolfim-ibm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was to run on the same "standard" port as other serving runtimes in OpenShift AI. But it's an env var, so can be anything in the end.