Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
261e9da
added toggle for evaluation step
sudivate Jan 27, 2020
ba26bc1
added param to varriables list
sudivate Jan 27, 2020
c1bee1c
corrected to matrices
sudivate Jan 27, 2020
b6732da
resolved linting
sudivate Jan 27, 2020
88b99ae
removed duplicate
sudivate Jan 27, 2020
a3f02f9
resolved linting
sudivate Jan 27, 2020
39207d6
resolved linting
sudivate Jan 27, 2020
41f4456
Merge branch 'master' of https://github.com/microsoft/MLOpsPython int…
sudivate Jan 28, 2020
1701c0d
added overide switch to cancellation
sudivate Jan 28, 2020
ef95fa9
added override cancellation flag
sudivate Jan 28, 2020
43d0824
reversed the condition on runevaluation flag
sudivate Jan 28, 2020
45a94b0
renamed variable
sudivate Jan 28, 2020
3821a42
reversed he coonditon on override run
sudivate Jan 28, 2020
9652e00
renamed variable for test
sudivate Jan 28, 2020
21739c7
Update proper build badge
dtzar Jan 28, 2020
f46947f
added default value to env vars
sudivate Jan 28, 2020
e5d1566
Merge branch 'sudivate/eval-switch' of https://github.com/microsoft/M…
sudivate Jan 28, 2020
9235f40
defined parameter
sudivate Jan 28, 2020
b63c489
added variable
sudivate Jan 28, 2020
8aa3865
corrected comment
sudivate Jan 28, 2020
e6c2bde
renamed flags
sudivate Jan 28, 2020
119fa1c
added util script
sudivate Jan 29, 2020
6882003
intial script to get environment
sudivate Jan 30, 2020
870a8b4
moved conda file
sudivate Jan 30, 2020
1a1ea46
merged conda file
sudivate Jan 30, 2020
a3d1c26
added enviroment support
sudivate Jan 30, 2020
ccdcd85
added path
sudivate Jan 30, 2020
06e874f
added args
sudivate Jan 30, 2020
1a9d67d
changed path for local testing
sudivate Jan 30, 2020
a8036a7
script to manage aml env
sudivate Jan 31, 2020
fb51eed
updated scripts
sudivate Jan 31, 2020
cd6db20
Merge branch 'master' of https://github.com/microsoft/MLOpsPython int…
sudivate Jan 31, 2020
1d6b9f4
Merge branch 'master' of https://github.com/microsoft/MLOpsPython int…
sudivate Feb 13, 2020
6839505
removed exception printing
sudivate Feb 13, 2020
a09aa6a
re usable env
sudivate Feb 13, 2020
8e55744
linting
sudivate Feb 13, 2020
a840247
fixed import
sudivate Feb 13, 2020
5978f7c
removed env var
sudivate Feb 13, 2020
121a822
from conda file
sudivate Feb 13, 2020
d13b509
from conda file
sudivate Feb 13, 2020
7b9af18
renamed file for test
sudivate Feb 13, 2020
ec98dc0
updated env name
sudivate Feb 13, 2020
c0949e8
updated path
sudivate Feb 13, 2020
7dbf9fd
updated doc
sudivate Feb 13, 2020
87cdecd
remove env json
sudivate Feb 14, 2020
588a663
Merge branch 'master'
sudivate Feb 28, 2020
7677dbc
import env helper
sudivate Feb 28, 2020
0264664
fix import
sudivate Feb 28, 2020
a20a5ac
pipeline variables for aml env
sudivate Feb 28, 2020
77ad98f
changed env name
sudivate Feb 28, 2020
32344ce
remove aml env
sudivate Feb 28, 2020
cece19d
adding env var for build id
sudivate Feb 28, 2020
178a698
change aml env name
sudivate Feb 28, 2020
2621b77
testing env
sudivate Feb 28, 2020
a0cc245
test env
sudivate Feb 28, 2020
9262909
delete unused
sudivate Feb 28, 2020
8cea674
print env
sudivate Feb 29, 2020
454b811
fixed name
sudivate Feb 29, 2020
700acab
adding env to runconfig
sudivate Feb 29, 2020
631141b
linting fix
sudivate Feb 29, 2020
ba85029
aml env name change
sudivate Feb 29, 2020
a949840
fixed aml env type
sudivate Feb 29, 2020
486e320
corrected env name
sudivate Feb 29, 2020
c24454b
removed extra underscore
sudivate Mar 2, 2020
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ WORKSPACE_NAME = 'aml-workspace'
EXPERIMENT_NAME = ''

# AML Compute Cluster Config
AML_ENV_NAME='diabetes_regression_training_env'
AML_COMPUTE_CLUSTER_NAME = 'train-cluster'
AML_COMPUTE_CLUSTER_CPU_SKU = 'STANDARD_DS2_V2'
AML_CLUSTER_MAX_NODES = '4'
Expand Down
2 changes: 2 additions & 0 deletions .pipelines/diabetes_regression-variables-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ variables:
value: diabetes_regression_model.pkl

# AML Compute Cluster Config
- name: AML_ENV_NAME
value: diabetes_regression_training_env
- name: AML_COMPUTE_CLUSTER_CPU_SKU
value: STANDARD_DS2_V2
- name: AML_COMPUTE_CLUSTER_NAME
Expand Down
1 change: 0 additions & 1 deletion bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def replaceprojectname(project_dir, project_name, rename_name):
r"ml_service/pipelines/diabetes_regression_build_train_pipeline.py", # NOQA: E501
r"ml_service/pipelines/diabetes_regression_verify_train_pipeline.py", # NOQA: E501
r"ml_service/util/create_scoring_image.py",
r"diabetes_regression/azureml_environment.json",
r"diabetes_regression/conda_dependencies.yml",
r"diabetes_regression/evaluate/evaluate_model.py",
r"diabetes_regression/register/register_model.py",
Expand Down
39 changes: 0 additions & 39 deletions diabetes_regression/azureml_environment.json

This file was deleted.

48 changes: 28 additions & 20 deletions diabetes_regression/conda_dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
# Conda environment specification. The dependencies defined in this file will
# be automatically provisioned for managed runs. These include runs against
# the localdocker, remotedocker, and cluster compute targets.

# Note that this file is NOT used to automatically manage dependencies for the
# local compute target. To provision these dependencies locally, run:
# conda env update --file conda_dependencies.yml

# Details about the Conda environment file format:
# https://conda.io/docs/using/envs.html#create-environment-file-by-hand

name: diabetes_regression_sklearn
# For managing Spark packages and configuration, see spark_dependencies.yml.
# Version of this configuration file's structure and semantics in AzureML.
# This directive is stored in a comment to preserve the Conda file structure.
# [AzureMlVersion] = 2

name: diabetes_regression_training_env
dependencies:
# The python interpreter version.
# Currently Azure ML Workbench only supports 3.5.2 and later.
- 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

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

- azureml-core==1.0.85

# Dependencies for scoring environment.

# You must list azureml-defaults as a pip dependency
- azureml-defaults==1.0.85
- inference-schema[numpy-support]==1.0.1
- azureml-dataprep==1.1.38
# Required packages for AzureML execution, history, and data preparation.
- azureml-model-management-sdk==1.0.1b6.post1
- azureml-sdk==1.0.74
- scipy==1.3.1
- scikit-learn==0.22
- pandas==0.25.3
- numpy==1.17.3
- joblib==0.14.0
- gunicorn==19.9.0
- flask==1.1.1
- inference-schema[numpy-support]
- azure
- azure-storage-blob
- azureml-dataprep
2 changes: 1 addition & 1 deletion diabetes_regression/scoring/inference_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ schemaFile:
sourceDirectory:
enableGpu: False
baseImage:
baseImageRegistry:
baseImageRegistry:
1 change: 0 additions & 1 deletion docs/code_description.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ The repository provides a template with folders structure suitable for maintaini

### Environment Definitions

- `diabetes_regression/azureml_environment.json` : Azure ML environment definition for the training environment, including base Docker image and a reference to `conda_dependencies.yml` Conda environment file.
- `diabetes_regression/conda_dependencies.yml` : Conda environment definition for the environment used for both training and scoring (Docker image in which train.py and score.py are run).
- `diabetes_regression/ci_dependencies.yml` : Conda environment definition for the CI environment.

Expand Down
18 changes: 9 additions & 9 deletions ml_service/pipelines/diabetes_regression_build_train_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from azureml.pipeline.core.graph import PipelineParameter
from azureml.pipeline.steps import PythonScriptStep
from azureml.pipeline.core import Pipeline, PipelineData
from azureml.core import Workspace, Environment
from azureml.core import Workspace
from azureml.core.runconfig import RunConfiguration
from azureml.core import Dataset
from ml_service.util.attach_compute import get_compute
from ml_service.util.env_variables import Env
from ml_service.util.manage_environment import get_environment
from sklearn.datasets import load_diabetes
import pandas as pd
import os
Expand All @@ -31,17 +32,16 @@ def main():
print("aml_compute:")
print(aml_compute)

# Create a reusable run configuration environment
# Read definition from diabetes_regression/azureml_environment.json
environment = Environment.load_from_directory(e.sources_directory_train)
if (e.collection_uri is not None and e.teamproject_name is not None):
builduri_base = e.collection_uri + e.teamproject_name
builduri_base = builduri_base + "/_build/results?buildId="
environment.environment_variables["BUILDURI_BASE"] = builduri_base
environment.register(aml_workspace)
# Create a reusable Azure ML environment
environment = get_environment(
aml_workspace, e.aml_env_name, create_new=False) # NOQA: E501

run_config = RunConfiguration()
run_config.environment = environment
if (e.collection_uri is not None and e.teamproject_name is not None):
builduri_base = e.collection_uri + e.teamproject_name
builduri_base = builduri_base + "/_build/results?buildId="
run_config.environment.environment_variables["BUILDURI_BASE"] = builduri_base # NOQA: E501

model_name_param = PipelineParameter(
name="model_name", default_value=e.model_name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from azureml.pipeline.steps import PythonScriptStep
from azureml.pipeline.core import Pipeline
from azureml.core import Workspace, Environment
from azureml.core import Workspace
from azureml.core.runconfig import RunConfiguration
from ml_service.util.attach_compute import get_compute
from ml_service.util.env_variables import Env
from ml_service.util.manage_environment import get_environment


def main():
Expand All @@ -26,19 +27,17 @@ def main():
print("aml_compute:")
print(aml_compute)

# Create a reusable run configuration environment
# Read definition from diabetes_regression/azureml_environment.json
# Create a reusable Azure ML environment
# Make sure to include `r-essentials'
# in diabetes_regression/conda_dependencies.yml
environment = Environment.load_from_directory(e.sources_directory_train)
environment = get_environment(
aml_workspace, e.aml_env_name, create_new=False) # NOQA: E501
run_config = RunConfiguration()
run_config.environment = environment
if (e.collection_uri is not None and e.teamproject_name is not None):
builduri_base = e.collection_uri + e.teamproject_name
builduri_base = builduri_base + "/_build/results?buildId="
environment.environment_variables["BUILDURI_BASE"] = builduri_base
environment.register(aml_workspace)

run_config = RunConfiguration()
run_config.environment = environment
run_config.environment.environment_variables["BUILDURI_BASE"] = builduri_base # NOQA: E501

train_step = PythonScriptStep(
name="Train Model",
Expand Down
5 changes: 5 additions & 0 deletions ml_service/util/env_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self):
self._run_evaluation = os.environ.get("RUN_EVALUATION", "true")
self._allow_run_cancel = os.environ.get(
"ALLOW_RUN_CANCEL", "true")
self._aml_env_name = os.environ.get("AML_ENV_NAME")

@property
def workspace_name(self):
Expand Down Expand Up @@ -156,3 +157,7 @@ def run_evaluation(self):
@property
def allow_run_cancel(self):
return self._allow_run_cancel

@property
def aml_env_name(self):
return self._aml_env_name
29 changes: 29 additions & 0 deletions ml_service/util/manage_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from azureml.core import Workspace, Environment
from ml_service.util.env_variables import Env
import os


def get_environment(
workspace: Workspace,
environment_name: str,
create_new: bool = False
):
try:
e = Env()
environments = Environment.list(workspace=workspace)
restored_environment = None
for env in environments:
if env == environment_name:
restored_environment = environments[environment_name]

if restored_environment is None or create_new:
new_env = Environment.from_conda_specification(environment_name, os.path.join(e.sources_directory_train, "conda_dependencies.yml")) # NOQA: E501
restored_environment = new_env
restored_environment.register(workspace)

if restored_environment is not None:
print(restored_environment)
return restored_environment
except Exception as e:
print(e)
exit(1)