Skip to content

Commit

Permalink
Remove env vars defined in RUNs
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Zhao <[email protected]>
  • Loading branch information
SimonYansenZhao committed Sep 26, 2024
1 parent 393c1a0 commit 2aebacf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"target": "deps",
"args": {
"COMPUTE": "cpu",
"EXTRAS": "dev,spark",
"EXTRAS": "[dev,spark]",
"GIT_REF": "",
"JDK_VERSION": "21",
"PYTHON_VERSION": "3.11"
Expand Down
4 changes: 3 additions & 1 deletion tests/ci/azureml_tests/aml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def get_or_create_environment(
python_version (str): python version, such as "3.11"
"""
compute = "gpu" if use_gpu else "cpu"
extras = "dev" + (",gpu" if use_gpu else "") + (",spark" if use_spark else "")
extras = (
"[dev" + (",gpu" if use_gpu else "") + (",spark" if use_spark else "") + "]"
)
dockerfile = pathlib.Path("tools/docker/Dockerfile")

# Docker's --build-args is not supported by AzureML Python SDK v2 as shown
Expand Down
17 changes: 11 additions & 6 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ ARG CONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_6
ARG ENV_NAME="Recommenders"
ARG RECO_LOCAL_DIR="./"
ARG RECO_DIR="/tmp/recommenders"
ARG RECO_GIT_URL="git+https://github.com/recommenders-team/recommenders.git"

# Install Conda
RUN wget -qO ${CONDA_FILE} ${CONDA_URL} && \
Expand All @@ -83,18 +84,22 @@ RUN wget -qO ${CONDA_FILE} ${CONDA_URL} && \
${CONDA_PREFIX}/bin/conda config --set auto_activate_base false

# Create Conda environment
RUN JDK=$(if [[ "${EXTRAS}" =~ spark ]]; then echo "openjdk=${JDK_VERSION}"; else echo ""; fi) \
${CONDA_PREFIX}/bin/conda create -n ${ENV_NAME} -c conda-forge -y python=${PYTHON_VERSION} pip ${JDK}
RUN ${CONDA_PREFIX}/bin/conda create -n ${ENV_NAME} -c conda-forge -y \
python=${PYTHON_VERSION} \
pip \
$(if [[ "${EXTRAS}" =~ spark ]]; then echo "openjdk=${JDK_VERSION}"; else echo ""; fi)

# Copy Recommenders into the image
COPY ${RECO_LOCAL_DIR} ${RECO_DIR}

# Install Recommenders and its dependencies
RUN RECO=$(if [ -z "${GIT_REF}" ]; then echo "${RECO_DIR}"; else echo "recommenders"; fi); \
RECO_URL=$(if [ -z "${GIT_REF}" ]; then echo ""; else echo "@git+https://github.com/recommenders-team/recommenders.git@${GIT_REF}"; fi); \
source ${CONDA_PREFIX}/bin/activate && \
RUN source ${CONDA_PREFIX}/bin/activate && \
conda activate ${ENV_NAME} && \
pip install ${RECO}$(if [ -z "${EXTRAS}" ]; then echo ""; else echo "[${EXTRAS}]"; fi)${RECO_URL} && \
if [ -z "${GIT_REF}" ]; then \
pip install ${RECO_DIR}${EXTRAS}; \
else \
pip install recommenders${EXTRAS}@${RECO_GIT_URL}@${GIT_REF}; \
fi && \
python -m ipykernel install --user --name ${ENV_NAME} --display-name "Python (${ENV_NAME})"

# Activate Recommenders Conda environment
Expand Down

0 comments on commit 2aebacf

Please sign in to comment.