Skip to content

Commit

Permalink
Dockerfile/shell script updates
Browse files Browse the repository at this point in the history
  • Loading branch information
joshanderson-kw committed Nov 3, 2021
1 parent e47a407 commit 09a0951
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 50 deletions.
30 changes: 22 additions & 8 deletions docker/smqtk_iqr_playground/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@ RUN pip3 install \
# Nice-to-haves
file-magic==0.4.0 \
ipython==7.14.0 \
# SMQTK packages
smqtk-core \
smqtk-classifier \
smqtk-dataprovider \
smqtk-iqr \
smqtk-relevancy \
smqtk-indexing \
smqtk-descriptors \
scikit-learn

RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py \
| python3 -
ENV PATH=/smqtk/.poetry/bin:$PATH

RUN mkdir /smqtk/
COPY docs /smqtk/source/docs
COPY poetry.lock /smqtk/source
COPY pyproject.toml /smqtk/source
COPY README.md /smqtk/source
COPY smqtk_iqr /smqtk/source/smqtk_iqr
RUN cd /smqtk/source && \
pip3 install -U pip && \
pip3 install .

###############################################################################
# COPY in FAISS wheel and install
#
Expand Down Expand Up @@ -97,11 +103,19 @@ RUN pip3 install /caffe-1.0-py3-none-any.whl \
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8

# Export language options to use UTF-8, desired by Click
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8

# Shim to expose legacy postgresql CLI tools
# TODO: Clean this up / modernize / don't be running a local database
RUN ln -s /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pg_ctl \
&& ln -s /usr/share/postgresql-common/pg_wrapper /usr/local/bin/postgres

# TODO: figure out a better way to do this
RUN ln -s /usr/local/lib/python3.6/dist-packages/smqtk_iqr/web/search_app/templates/base.html \
/usr/local/lib/python3.6/dist-packages/smqtk_iqr/web/search_app/modules/iqr/templates/base.html

# Add ``smqtk`` user
RUN useradd -mr -s /bin/bash smqtk \
# sudo permission for modifying permissions at runtime (see entrypoint.sh).
Expand Down
47 changes: 5 additions & 42 deletions docker/smqtk_iqr_playground/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,29 +159,12 @@ then
touch "${STP_IMF}"
fi

# Tile discovered images if requested and hasn't happened yet.
if [ -n "${TILE_IMAGES}" -a ! -e "${STP_GIT}" ]
# Compute descriptors
echo "Computing descriptors"
if [ ! -e "${STP_CMD}" ]
then
echo "Generating tiles for images ($(wc -l "${IMAGE_DIR_FILELIST}" | cut -d' ' -f1) images)"
IMG_TILES_DIR="image_tiles"
mkdir -p "${IMG_TILES_DIR}"
# Check if GNU parallel is available.
if [ -n "$(which parallel 2>/dev/null)" ]
then
cat "${IMAGE_DIR_FILELIST}" | parallel "
generate_image_transform -c \"${CONFIG_DIR}/${SMQTK_GEN_IMG_TILES}\" \
-i \"{}\" -o \"${IMG_TILES_DIR}\"
"
else
cat "${IMAGE_DIR_FILELIST}" | \
xargs -I '{}' generate_image_transform \
-c "${CONFIG_DIR}/${SMQTK_GEN_IMG_TILES}" -i '{}' \
-o "${IMG_TILES_DIR}"
fi
# Use these tiles for new imagelist
mv "${IMAGE_DIR_FILELIST}" "${IMAGE_DIR_FILELIST}.ORIG"
find "${IMG_TILES_DIR}" -type f >"${IMAGE_DIR_FILELIST}"
touch "${STP_GIT}"
iqr_app_model_generation -c "${CONFIG_DIR}/${SMQTK_GUI_IQR_CONFIG}" "${CONFIG_DIR}/${SMQTK_REST_IQR_CONFIG}" -t "Data-set Iqr" "${IMAGE_DIR}/*.*" &> "${LOG_CMD}"
touch "${STP_CMD}"
fi

# Tail build logs until they are done
Expand All @@ -191,26 +174,6 @@ then
tail -F "${LOG_GIT}" "${LOG_CMD}" "${LOG_NIT}" &
echo "$!" >"${TAIL_PID}"

# Compute descriptors
if [ ! -e "${STP_CMD}" ]
then
compute_many_descriptors \
-v -b ${DESCRIPTOR_BATCH_SIZE} --check-image \
-c "${CONFIG_DIR}/${SMQTK_CMD_CONFIG}" \
-f "${IMAGE_DIR_FILELIST}" -p "${DESCRIPTOR_PROCESSED_CSV}" \
&> "${LOG_CMD}"
touch "${STP_CMD}"
fi

# Step to build nn-index from build descriptor index
if [ ! -e "${STP_NIT}" ]
then
smqtk-nn-index-tool -v \
build "${CONFIG_DIR}/${SMQTK_NN_INDEX_TOOL_CONFIG}" \
&> "${LOG_NIT}"
touch "${STP_NIT}"
fi

# Stop log tail
kill $(cat "${TAIL_PID}")
fi
Expand Down
1 change: 1 addition & 0 deletions docker/smqtk_iqr_playground/run_container.cpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ then
-p ${IQR_GUI_PORT_PUBLISH}:5000 \
-p ${IQR_REST_PORT_PUBLISH}:5001 \
-v "${IMAGE_DIR}":/images \
-v /home/local/KHQ/josh.anderson/Projects/SMQTK/SMQTK-Descriptors/smqtk_descriptors:/usr/local/lib/python3.6/dist-packages/smqtk_descriptors/ \
--name "${CONTAINER_NAME}" \
${IQR_CONTAINER}:${IQR_CONTAINER_VERSION} -b "$@"
fi
Expand Down
2 changes: 2 additions & 0 deletions smqtk_iqr/web/iqr_service/iqr_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
)
from smqtk_indexing import NearestNeighborsIndex
from smqtk_relevancy import RankRelevancyWithFeedback
import smqtk_relevancy.impls.rank_relevancy.margin_sampling
import smqtk_relevancy.impls.rank_relevancy.wrap_classifier
from smqtk_dataprovider.impls.data_element.memory import DataMemoryElement

from smqtk_iqr.web import SmqtkWebApp
Expand Down

0 comments on commit 09a0951

Please sign in to comment.