Skip to content
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

Upgrade dependencies for docker images and add py3.11 test jobs. #31

Merged
merged 1 commit into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10" ]
python-version: [ "3.10", "3.11" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -31,6 +31,7 @@ jobs:
pytest --cov=app .
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/[email protected]
if: ${{ matrix.python-version == '3.11' }} # Only upload coverage reports for the latest Python version
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Analysing the code with pylint
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
ARG TORCH_VERSION=2.1.2
ARG TORCH_VERSION=2.3.0
ARG CUDA_VERSION=12.1
FROM pytorch/pytorch:${TORCH_VERSION}-cuda${CUDA_VERSION}-cudnn8-runtime

WORKDIR /opt/NekoImageGallery

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt
RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -r requirements.txt

RUN mkdir -p /opt/models && \
export PYTHONDONTWRITEBYTECODE=1 && \
huggingface-cli download openai/clip-vit-large-patch14 'model.safetensors' '*.txt' '*.json' --local-dir /opt/models/clip && \
huggingface-cli download google-bert/bert-base-chinese 'model.safetensors' '*.txt' '*.json' --local-dir /opt/models/bert && \
huggingface-cli download pk5ls20/PaddleModel 'PaddleOCR2Pytorch/ch_ptocr_v4_det_infer.pth' 'PaddleOCR2Pytorch/ch_ptocr_v4_rec_infer.pth' \
Expand Down
2 changes: 1 addition & 1 deletion app/Services/upload_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def _upload_task(self, img: Image.Image, img_data: ImageData, img_bytes: b

async def upload_image(self, img: Image.Image, img_data: ImageData, img_bytes: bytes, skip_ocr: bool):
await self._queue.put((img, img_data, img_bytes, skip_ocr))
logger.info("Image {} added to upload queue. Queue Length: {} [+1]", img_data.id, self._queue.qsize())
logger.success("Image {} added to upload queue. Queue Length: {} [+1]", img_data.id, self._queue.qsize())

def get_queue_size(self):
return self._queue.qsize()
7 changes: 4 additions & 3 deletions cpu-only.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM python:3.10-slim-bookworm
FROM python:3.11-slim-bookworm

RUN pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cpu --no-cache-dir
RUN PYTHONDONTWRITEBYTECODE=1 pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cpu --no-cache-dir

WORKDIR /opt/NekoImageGallery

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt
RUN PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir -r requirements.txt

RUN mkdir -p /opt/models && \
export PYTHONDONTWRITEBYTECODE=1 && \
huggingface-cli download openai/clip-vit-large-patch14 'model.safetensors' '*.txt' '*.json' --local-dir /opt/models/clip && \
huggingface-cli download google-bert/bert-base-chinese 'model.safetensors' '*.txt' '*.json' --local-dir /opt/models/bert && \
huggingface-cli download pk5ls20/PaddleModel 'PaddleOCR2Pytorch/ch_ptocr_v4_det_infer.pth' 'PaddleOCR2Pytorch/ch_ptocr_v4_rec_infer.pth' \
Expand Down
1 change: 0 additions & 1 deletion tests/api/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_upload_bad_img_file(test_client):
files={'image_file': bad_img_file},
headers={'x-admin-token': TEST_ADMIN_TOKEN},
params={'local': True})
print(resp.content)
assert resp.status_code == 422


Expand Down
Loading