Skip to content

Commit

Permalink
Sudivate/fixdeployaci (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
sudivate authored Feb 6, 2020
1 parent 275ba5c commit 08bc547
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 54 deletions.
43 changes: 20 additions & 23 deletions diabetes_regression/ci_dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
name: mlopspython_ci

dependencies:

# The python interpreter version.
- python=3.7.5
- python=3.7.5

# dependencies with versions aligned with conda_dependencies.yml.
- numpy=1.18.1
- pandas=1.0.0
- scikit-learn=0.22.1

# dependencies for MLOps with R.
- r=3.6.0
- r-essentials=3.6.0
- numpy=1.18.1
- pandas=1.0.0
- scikit-learn=0.22.1
# dependencies for MLOps with R.
- r=3.6.0
- r-essentials=3.6.0

- pip=20.0.2
- pip:

# dependencies with versions aligned with conda_dependencies.yml.
- azureml-sdk==1.0.79
- pip=20.0.2
- pip:
# dependencies with versions aligned with conda_dependencies.yml.
- azureml-sdk==1.0.85

# Additional pip dependencies for the CI environment.
- pytest==5.3.1
- pytest-cov==2.8.1
- requests==2.22.0
- python-dotenv==0.10.3
- flake8==3.7.9
- flake8_formatter_junit_xml==0.0.6
- azure-cli==2.0.77
- tox==3.14.3
# Additional pip dependencies for the CI environment.
- pytest==5.3.1
- pytest-cov==2.8.1
- requests==2.22.0
- python-dotenv==0.10.3
- flake8==3.7.9
- flake8_formatter_junit_xml==0.0.6
- azure-cli==2.0.81
- tox==3.14.3
34 changes: 16 additions & 18 deletions diabetes_regression/conda_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,28 @@
name: diabetes_regression_sklearn

dependencies:

# The python interpreter version.
- python=3.7.5
- python=3.7.5

# Required by azureml-defaults, installed separately through Conda to
# get a prebuilt version and not require build tools for the install.
- psutil=5.6 #latest

- numpy=1.18.1
- pandas=1.0.0
- scikit-learn=0.22.1
#- r-essentials
#- tensorflow
#- keras
- psutil=5.6 #latest

- pip=20.0.2
- pip:
- numpy=1.18.1
- pandas=1.0.0
- scikit-learn=0.22.1
#- r-essentials
#- tensorflow
#- keras

# Dependencies for training environment.
- pip=20.0.2
- pip:
# Dependencies for training environment.

- azureml-core==1.0.79
- azureml-core==1.0.85

# Dependencies for scoring environment.
# Dependencies for scoring environment.

# You must list azureml-defaults as a pip dependency
- azureml-defaults==1.0.79
- inference-schema[numpy-support]==1.0.1
# You must list azureml-defaults as a pip dependency
- azureml-defaults==1.0.85
- inference-schema[numpy-support]==1.0.1
17 changes: 7 additions & 10 deletions environment_setup/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
FROM conda/miniconda3

LABEL org.label-schema.vendor = "Microsoft" \
org.label-schema.url = "https://hub.docker.com/r/microsoft/mlopspython" \
org.label-schema.vcs-url = "https://github.com/microsoft/MLOpsPython"
org.label-schema.url = "https://hub.docker.com/r/microsoft/mlopspython" \
org.label-schema.vcs-url = "https://github.com/microsoft/MLOpsPython"

COPY diabetes_regression/ci_dependencies.yml /setup/

RUN conda env create -f /setup/ci_dependencies.yml

# activate environment
ENV PATH /usr/local/envs/mlopspython_ci/bin:$PATH
RUN /bin/bash -c "source activate mlopspython_ci"

# Verify conda installation.
# This serves as workaround for https://github.com/conda/conda/issues/8537 (conda env create doesn't fail
# if pip installation fails, for example due to a wrong package version).
# The `az` command is not available if pip has not run (and installed azure-cli).
RUN az --version
RUN conda update -n base -c defaults conda && \
conda install python=3.7.5 && \
conda env create -f /setup/ci_dependencies.yml && \
/bin/bash -c "source activate mlopspython_ci" && \
az --version
8 changes: 6 additions & 2 deletions ml_service/util/create_scoring_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from azureml.core import Workspace
from azureml.core.image import ContainerImage, Image
from azureml.core.model import Model
import shutil
from ml_service.util.env_variables import Env

e = Env()
Expand All @@ -29,8 +30,10 @@
sources_dir = 'diabetes_regression'
path_to_scoring = os.path.join(".", sources_dir, "scoring")
cwd = os.getcwd()
# Copy conda_dependencies.yml into scoring as this method does not accept relative paths. # NOQA: E501
shutil.copy(os.path.join(".", sources_dir,
"conda_dependencies.yml"), path_to_scoring)
os.chdir(path_to_scoring)

image_config = ContainerImage.image_configuration(
execution_script=e.score_script,
runtime="python",
Expand All @@ -40,7 +43,8 @@
)

image = Image.create(
name=e.image_name, models=[model], image_config=image_config, workspace=ws
name=e.image_name, models=[
model], image_config=image_config, workspace=ws
)

os.chdir(cwd)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/code_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_train_model():
run = Mock(Run)
reg = train_model(run, data, alpha=1.2)

run.log.assert_called_with("mse", 0.029843893480256872,
run.log.assert_called_with("mse", 0.029843893480257067,
description='Mean squared error metric')

preds = reg.predict([[1], [2]])
Expand Down

0 comments on commit 08bc547

Please sign in to comment.