Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
07f985a
Adds Observability Modules
Jul 2, 2020
5adb1bc
Fixes YML file
Jul 2, 2020
5bc9778
Fixes flake8 errors
Jul 2, 2020
cb2694a
removes python-dotenv==0.10.3 dependency
Jul 2, 2020
534eaec
Chages the AML_REBUILD_ENVIRONMENT to false
Jul 3, 2020
56a20bf
Fixes the AML image snapshot path
Jul 3, 2020
0f614c4
Satisfies Flake8
Jul 3, 2020
bb0d158
Integrates Observability onto Pipeline and one script
Jul 3, 2020
3a619da
Chamnges factory to register_loggers
Jul 3, 2020
ff513b3
Adds app_insights_connection_string to Env class
Jul 3, 2020
f61d444
Integrates observability with ml_service
Jul 3, 2020
b2d81d1
Satisfies Flake8
Jul 3, 2020
0904c59
Integrates diabetes_regression scripts with observability
Jul 3, 2020
cbd100a
Changes Observability to add AppInsightsLoggers to list of loggers on…
Jul 3, 2020
704d345
Adds APP_INSIGHTS_CONNECTION_STRING to logger_interface
Jul 3, 2020
421c14c
Removes the dependency to Env object
Jul 6, 2020
bbc871a
Satisfies Flake8
Jul 6, 2020
cc95eaf
Adds dataclasses to conda_dependencies.yml
Jul 6, 2020
e1a76f8
Fixes YAML indentation
Jul 6, 2020
07e432f
Changes log_metric to log
Jul 6, 2020
b48da8e
Adds more scripts to use Observability and get app_insight_connectoin_
Jul 6, 2020
b25c7e2
Remove AML_REBUILD_ENVIRONMENT flag
Jul 6, 2020
b814d47
Resolves the conflicts
Jul 6, 2020
13841e2
Adds diabetes_regression to scoring path
Jul 6, 2020
66cffef
Adds dataclasses
Jul 6, 2020
8328b88
Adds dataclasses to conda_dependencies_scorecopy.yml
Jul 6, 2020
8cac588
Adds python-dotenv and opencensus to conda_dependencies_scorecopy.yml
Jul 6, 2020
c113423
Merges with master
Jul 9, 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
Prev Previous commit
Next Next commit
Fixes the AML image snapshot path
  • Loading branch information
Maysam Mokarian
Maysam Mokarian committed Jul 3, 2020
commit 56a20bff69320023cb6e7ce516df58b29c77e42d
8 changes: 4 additions & 4 deletions .pipelines/diabetes_regression-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ stages:
inputs:
azureSubscription: '$(WORKSPACE_SVC_CONNECTION)'
scriptLocation: inlineScript
workingDirectory: $(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/scoring
workingDirectory: $(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/diabetes_regression/scoring
inlineScript: |
set -e # fail on error

Expand Down Expand Up @@ -101,7 +101,7 @@ stages:
inputs:
azureSubscription: '$(WORKSPACE_SVC_CONNECTION)'
scriptLocation: inlineScript
workingDirectory: $(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/scoring
workingDirectory: $(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/diabetes_regression/scoring
inlineScript: |
set -e # fail on error

Expand Down Expand Up @@ -138,8 +138,8 @@ stages:
- template: diabetes_regression-package-model-template.yml
parameters:
modelId: $(MODEL_NAME):$(MODEL_VERSION)
scoringScriptPath: '$(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/scoring/score.py'
condaFilePath: '$(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/conda_dependencies.yml'
scoringScriptPath: '$(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/diabetes_regression/scoring/score.py'
condaFilePath: '$(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/diabetes_regression/conda_dependencies.yml'
- script: echo $(IMAGE_LOCATION) >image_location.txt
displayName: "Write image location file"
- task: AzureWebAppContainer@1
Expand Down
10 changes: 5 additions & 5 deletions .pipelines/diabetes_regression-variables-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ variables:
# Source Config
# The directory containing the scripts for training, evaluating, and registering the model
- name: SOURCES_DIR_TRAIN
value: diabetes_regression
value: .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? This environment variable is used to keep the name of the folder, since the name will likely change during bootstrap. For this reason, we should avoid hardcoding this name in the pipeline and code.

# The path to the model training script under SOURCES_DIR_TRAIN
- name: TRAIN_SCRIPT_PATH
value: training/train_aml.py
value: diabetes_regression/training/train_aml.py
# The path to the model evaluation script under SOURCES_DIR_TRAIN
- name: EVALUATE_SCRIPT_PATH
value: evaluate/evaluate_model.py
value: diabetes_regression/evaluate/evaluate_model.py
# The path to the model registration script under SOURCES_DIR_TRAIN
- name: REGISTER_SCRIPT_PATH
value: register/register_model.py
value: diabetes_regression/register/register_model.py
# The path to the model scoring script relative to SOURCES_DIR_TRAIN
- name: SCORE_SCRIPT
value: scoring/score.py
value: diabetes_regression/scoring/score.py


# Azure ML Variables
Expand Down
4 changes: 2 additions & 2 deletions diabetes_regression/evaluate/evaluate_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from azureml.core import Run
import argparse
import traceback
from util.model_helper import get_model
from diabetes_regression.util.model_helper import get_model

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Jenny So (@j-so) mentioned, all the references to diabetes_regression by name will not work when someone bootstraps and renames the project. We should find a way to reference this using a variable. Both in the python files and in the pipelines.


run = Run.get_context()

Expand All @@ -42,7 +42,7 @@
# load_dotenv()
# sources_dir = os.environ.get("SOURCES_DIR_TRAIN")
# if (sources_dir is None):
# sources_dir = 'diabetes_regression'
# sources_dir = '.'
# path_to_util = os.path.join(".", sources_dir, "util")
# sys.path.append(os.path.abspath(path_to_util)) # NOQA: E402
# from model_helper import get_model
Expand Down
2 changes: 1 addition & 1 deletion diabetes_regression/register/register_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def main():
print("Getting registration parameters")

# Load the registration parameters from the parameters file
with open("parameters.json") as f:
with open("diabetes_regression/parameters.json") as f:
pars = json.load(f)
try:
register_args = pars["registration"]
Expand Down
2 changes: 1 addition & 1 deletion diabetes_regression/scoring/parallel_batchscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import joblib
import sys
from typing import List
from util.model_helper import get_model
from diabetes_regression.util.model_helper import get_model
from azureml.core import Model

model = None
Expand Down
4 changes: 2 additions & 2 deletions diabetes_regression/training/train_aml.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import argparse
import joblib
import json
from train import split_data, train_model, get_model_metrics
from diabetes_regression.training.train import split_data, train_model, get_model_metrics


def register_dataset(
Expand Down Expand Up @@ -111,7 +111,7 @@ def main():
print("Getting training parameters")

# Load the training parameters from the parameters file
with open("parameters.json") as f:
with open("diabetes_regression/parameters.json") as f:
pars = json.load(f)
try:
train_args = pars["training"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def main():
load_dotenv()
sources_dir = os.environ.get("SOURCES_DIR_TRAIN")
if (sources_dir is None):
sources_dir = 'diabetes_regression'
sources_dir = '.'
workspace_name = os.environ.get("WORKSPACE_NAME")
experiment_name = os.environ.get("EXPERIMENT_NAME")
resource_group = os.environ.get("RESOURCE_GROUP")
Expand Down
2 changes: 1 addition & 1 deletion ml_service/util/create_scoring_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
model = Model(ws, name=e.model_name, version=e.model_version)
sources_dir = e.sources_directory_train
if (sources_dir is None):
sources_dir = 'diabetes_regression'
sources_dir = '.'
score_script = os.path.join(".", sources_dir, e.score_script)
score_file = os.path.basename(score_script)
path_to_scoring = os.path.dirname(score_script)
Expand Down
15 changes: 7 additions & 8 deletions ml_service/util/manage_environment.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@

import os
from azureml.core import Workspace, Environment
from ml_service.util.env_variables import Env
from azureml.core.runconfig import DEFAULT_CPU_IMAGE, DEFAULT_GPU_IMAGE


def get_environment(
workspace: Workspace,
environment_name: str,
conda_dependencies_file: str,
create_new: bool = False,
enable_docker: bool = None,
use_gpu: bool = False
workspace: Workspace,
environment_name: str,
conda_dependencies_file: str,
create_new: bool = False,
enable_docker: bool = None,
use_gpu: bool = False
):
try:
e = Env()
Expand All @@ -24,7 +23,7 @@ def get_environment(
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_file), # NOQA: E501
os.path.join(e.sources_directory_train, "diabetes_regression/" + conda_dependencies_file), # NOQA: E501
) # NOQA: E501
restored_environment = new_env
if enable_docker is not None:
Expand Down