Skip to content
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
54 changes: 21 additions & 33 deletions python/AzureTranslation/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1.2
# syntax=docker/dockerfile:1.4

#############################################################################
# NOTICE #
Expand Down Expand Up @@ -29,47 +29,28 @@
ARG BUILD_REGISTRY
ARG BUILD_TAG=latest

ARG RUN_TESTS=false
# To enable GPU resources, update
# below line to BUILD_TYPE=gpu
ARG BUILD_TYPE=cpu

FROM ${BUILD_REGISTRY}openmpf_python_executor_ssb:${BUILD_TAG} as download_python_packages


RUN pip install --no-cache-dir langcodes

RUN apt-get update && \
apt-get install -y git git-lfs && \
git lfs install && \
rm -rf /var/lib/apt/lists/*
FROM ${BUILD_REGISTRY}openmpf_python_component_build:${BUILD_TAG} AS python_build

# Install WtP and spaCy
RUN pip install --upgrade pip && \
pip install "spacy>=3.7.4" && \
pip install "wtpsplit>=1.3.0"

# Modify to add downloads for other models of interest.
RUN mkdir /wtp_models && cd /wtp_models && \
git clone https://huggingface.co/benjamin/wtp-bert-mini && \
python3 -m spacy download xx_sent_ud_sm
FROM ${BUILD_REGISTRY}openmpf_python_executor_ssb:${BUILD_TAG} AS cpu_component

########################################################################
FROM download_python_packages as cpu_component_build
RUN pip install torch --index-url https://download.pytorch.org/whl/cpu

########################################################################
FROM download_python_packages as gpu_component_build

# Environment variables required by nvidia runtime.
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ARG BUILD_TYPE

RUN pip install torch
RUN --mount=from=python_build,source=/home/mpf/openmpf-projects/openmpf-python-component-sdk/detection/nlp_text_splitter,target=/tmp/nlp_text_splitter \
<<eot
cd /tmp/nlp_text_splitter
if [[ ${BUILD_TYPE,,} = gpu ]]; then
./install.sh --gpu
else
./install.sh
fi
eot

########################################################################

FROM ${BUILD_TYPE}_component_build as component_final
ARG RUN_TESTS=false

RUN --mount=target=.,readwrite \
install-component.sh; \
Expand All @@ -81,3 +62,10 @@ LABEL org.label-schema.license="Apache 2.0" \
org.label-schema.url="https://openmpf.github.io" \
org.label-schema.vcs-url="https://github.com/openmpf/openmpf-components" \
org.label-schema.vendor="MITRE"

FROM cpu_component AS gpu_component

ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

FROM ${BUILD_TYPE}_component
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import mpf_component_api as mpf
import mpf_component_util as mpf_util

from nlp_text_splitter.text_splitter import TextSplitter, TextSplitterModel
from nlp_text_splitter import TextSplitterModel, TextSplitter

from . import convert_language_code

Expand Down
27 changes: 0 additions & 27 deletions python/AzureTranslation/nlp_text_splitter/__init__.py

This file was deleted.

263 changes: 0 additions & 263 deletions python/AzureTranslation/nlp_text_splitter/text_splitter.py

This file was deleted.

Loading