-
Notifications
You must be signed in to change notification settings - Fork 45
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
chore: Migrate from Poetry to UV, added health checkpoint, and improved dockerimage #15
base: main
Are you sure you want to change the base?
Conversation
spa5k
commented
Mar 4, 2025
•
edited
Loading
edited
- Add .dockerignore to optimize Docker build context
- Refactor docker-compose files for CPU and GPU modes to add health check.
- Update Dockerfile with multi-stage build and improved caching
- Add Makefile for simplified project management
- Implement health check endpoint in document converter route
- Optimize container runtime and model download process
- Improve documentation and setup instructions
- Add .dockerignore to optimize Docker build context - Refactor docker-compose files for CPU and GPU modes - Update Dockerfile with multi-stage build and improved caching - Add Makefile for simplified project management - Implement health check endpoint in document converter route - Optimize container runtime and model download process - Improve documentation and setup instructions
@drmingler do you mind taking a look? |
@spa5k Awesome work! Thank you. I will have a look and get back. Meanwhile can we have a unified lint rule so that we can avoid modifying the code formatting? |
Sure, I tried not to change much formatting, will reset wherever it happened. UV also provides a formatter, maybe it can be used |
What about this? Let's merge this, then I will create a PR to implement Ruff, as a GitHub action, and a pre commit in next PR, otherwise, there will be too many changes in this PR. |
Okay that makes sense. I will merge this over the weekend. Thank you |
…type safety and API documentation - Add comprehensive response examples and status codes - Introduce JobStatus and ImageType enums for better type safety - Enhance route error handling and status reporting - Add detailed field descriptions and validation - Improve health check endpoint with more granular service status reporting
Thanks, the PR is now in quite good stage, I tested the caching, and schema changes, including generating SDK using it for Go, and everything seems to be working well. |
```bash | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
curl -LsSf https://astral.sh/uv/install.sh | sh |
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.
Can we also add instructions on how to install uv for those using windows or add a link to the uv installation doc? @spa5k
README.md
Outdated
make docker-run-gpu | ||
|
||
# Or build and run with multiple workers | ||
make docker-run-gpu WORKER_COUNT=3 | ||
``` |
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.
Should be "docker-start-cpu" not "docker-run-gpu"
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.
…build and runtime performance - Simplify Dockerfile with single-stage build - Improve PyTorch and EasyOCR model installation based on system architecture - Update docker-compose files to remove runtime target - Add auto-detection for CPU/GPU docker start in Makefile - Enhance .dockerignore with additional Python-related exclusions - Add entrypoint script for consistent container startup
- Introduce detect_gpu.sh script for dynamic GPU and Docker configuration detection - Update docker-compose.cpu.yml and docker-compose.gpu.yml to use uv for running commands - Enhance Dockerfile with multi-stage build, improved GPU/CPU detection, and model downloading - Add NVIDIA GPU capabilities and platform configuration in Docker Compose files - Improve runtime and build performance with better caching and environment setup
Can you check the GPU part now? If it is not working, please move the pytorch and model downloads part to the runtime stage |
try: | ||
result = document_converter_service.get_single_document_task_result(job_id) | ||
|
||
# Return 202 Accepted if job is still in progress | ||
if result.status in ["IN_PROGRESS"]: | ||
return JSONResponse( | ||
status_code=status.HTTP_202_ACCEPTED, | ||
content=result.dict(exclude_none=True) | ||
) | ||
|
||
# Return 422 for failed jobs | ||
if result.status == "FAILURE": | ||
return JSONResponse( | ||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, | ||
content=result.dict(exclude_none=True) | ||
) | ||
|
||
# Return 200 OK for successful jobs | ||
return JSONResponse( | ||
status_code=status.HTTP_200_OK, | ||
content=result.dict(exclude_none=True) | ||
) | ||
except KeyError: | ||
raise HTTPException( | ||
status_code=status.HTTP_404_NOT_FOUND, | ||
detail=f"Job not found: {job_id}" | ||
) |
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.
Please take this off, during job processing we do not raise errors, we return a status of FAILURE if the job failed and the reason for the failure in the error field. It was intentionally done that way.
result = document_converter_service.get_batch_conversion_task_result(job_id) | ||
|
||
# Return 202 Accepted if the batch job or any sub-job is still in progress | ||
if result.status in ["IN_PROGRESS"] or any( | ||
job.status in ["IN_PROGRESS"] | ||
for job in result.conversion_results | ||
): | ||
return JSONResponse( | ||
status_code=status.HTTP_202_ACCEPTED, | ||
content=result.dict(exclude_none=True) | ||
) | ||
|
||
# Return 422 for failed batch jobs | ||
if result.status == "FAILURE" or any( | ||
job.status == "FAILURE" | ||
for job in result.conversion_results | ||
): | ||
return JSONResponse( | ||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, | ||
content=result.dict(exclude_none=True) | ||
) | ||
|
||
# Return 200 OK for successful batch jobs (all success) | ||
return JSONResponse( | ||
status_code=status.HTTP_200_OK, | ||
content=result.dict(exclude_none=True) | ||
) | ||
except KeyError: | ||
raise HTTPException( | ||
status_code=status.HTTP_404_NOT_FOUND, | ||
detail=f"Batch job not found: {job_id}" | ||
) |
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.
Same here
I will test on gpu and get back to you. @spa5k |