Skip to content
Draft
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
36 changes: 34 additions & 2 deletions .github/workflows/publish_translation_worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

publish-inference-worker:
publish-inference-c2translate-worker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
Expand All @@ -101,7 +101,39 @@ jobs:
- name: Build and push image
uses: docker/build-push-action@v7
with:
target: inference-worker
target: inference-c2translate-worker
context: ./workers/translation-worker
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

publish-inference-torch-worker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: icij/datashare-translation-inference-worker
tags: |
type=match,pattern=translation-worker-(.*),group=1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Login to Docker Hub
uses: docker/login-action@v4
with:
# You'll need to set these secrets
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v7
with:
target: inference-torch-worker
context: ./workers/translation-worker
platforms: linux/amd64
push: true
Expand Down
26 changes: 23 additions & 3 deletions workers/translation-worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ RUN rm -rf ~/.cache/pip
ENTRYPOINT ["entrypoints/io_worker.sh"]


FROM translation-worker-builder AS inference-worker
FROM translation-worker-builder AS inference-c2translate-worker
# Install deps first to optimize layer cache
RUN --mount=type=cache,target=~/.cache/uv \
--mount=type=bind,source=uv.dist.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync -v --frozen --no-editable --no-install-project --extra inference
uv sync -v --frozen --no-editable --no-install-project --extra c2translate

# Then copy code
ADD uv.dist.lock ./uv.lock
Expand All @@ -48,7 +48,27 @@ ADD translation_worker ./translation_worker/
ADD entrypoints/inference_worker.sh ./entrypoints/inference_worker.sh

# Then install service
RUN --mount=type=cache,target=~/.cache/uv uv sync -v --frozen --no-editable --extra inference
RUN --mount=type=cache,target=~/.cache/uv uv sync -v --frozen --no-editable --extra c2translate
RUN rm -rf ~/.cache/pip

ENTRYPOINT ["entrypoints/inference_worker.sh"]


FROM translation-worker-builder AS inference-torch-worker
# Install deps first to optimize layer cache
RUN --mount=type=cache,target=~/.cache/uv \
--mount=type=bind,source=uv.dist.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync -v --frozen --no-editable --no-install-project --extra torch

# Then copy code
ADD uv.dist.lock ./uv.lock
ADD pyproject.toml README.md ./
ADD translation_worker ./translation_worker/
ADD entrypoints/inference_worker.sh ./entrypoints/inference_worker.sh

# Then install service
RUN --mount=type=cache,target=~/.cache/uv uv sync -v --frozen --no-editable --extra torch
RUN rm -rf ~/.cache/pip

ENTRYPOINT ["entrypoints/inference_worker.sh"]
12 changes: 6 additions & 6 deletions workers/translation-worker/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ dependencies = "translation_worker.dependencies:REGISTRY"
worker_config_cls = "translation_worker.config:WORKER_CONFIG_CLS"

[project.optional-dependencies]
inference = ['datashare-translation-worker[argos_inference]']
argos_inference = [
inference = ['datashare-translation-worker[c2translate]']
c2translate = [
"argostranslate==1.11.0",
]
hunyuan_inference = [
"torch>=2.11.0",
"transformers>=5.12.1",
"accelerate>=1.14.0",
torch = [
"torch==2.11.1",
"transformers==5.12.1",
"accelerate==1.14.0",
]

[tool.uv.sources]
Expand Down
Loading