diff --git a/.github/workflows/test_lint.yml b/.github/workflows/test_lint.yml index 233abf5..4bcf9f8 100644 --- a/.github/workflows/test_lint.yml +++ b/.github/workflows/test_lint.yml @@ -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 }} @@ -31,6 +31,7 @@ jobs: pytest --cov=app . - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v4.2.0 + 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 diff --git a/Dockerfile b/Dockerfile index 599600d..598ce17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -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 @@ -6,9 +6,10 @@ 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' \ diff --git a/app/Services/upload_service.py b/app/Services/upload_service.py index baa025d..9a5313f 100644 --- a/app/Services/upload_service.py +++ b/app/Services/upload_service.py @@ -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() diff --git a/cpu-only.Dockerfile b/cpu-only.Dockerfile index fb83ae1..e05fec3 100644 --- a/cpu-only.Dockerfile +++ b/cpu-only.Dockerfile @@ -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' \ diff --git a/tests/api/test_upload.py b/tests/api/test_upload.py index a6fae14..a19bf01 100644 --- a/tests/api/test_upload.py +++ b/tests/api/test_upload.py @@ -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