Skip to content

Commit

Permalink
Merge pull request #31 from hv0905/py311v2
Browse files Browse the repository at this point in the history
Upgrade dependencies for docker images and add py3.11 test jobs.
  • Loading branch information
hv0905 authored May 26, 2024
2 parents 6670d9a + d71b0d8 commit 799d6e1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
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

0 comments on commit 799d6e1

Please sign in to comment.