Skip to content

Commit 1d2d773

Browse files
authored
Add an env var flag to recreate AMLS Environment (#230)
1 parent d531b2e commit 1d2d773

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ RUN_EVALUATION = 'true'
4848

4949
# Set to true cancels the Azure ML pipeline run when evaluation criteria are not met.
5050
ALLOW_RUN_CANCEL = 'true'
51+
52+
# Flag to allow rebuilding the AML Environment after it was built for the first time. This enables dependency updates from conda_dependencies.yaml.
53+
AML_REBUILD_ENVIRONMENT = 'false'

.pipelines/diabetes_regression-variables-template.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@ variables:
6666
# For debugging deployment issues. Specify a build id with the MODEL_BUILD_ID pipeline variable at queue time
6767
# to skip training and deploy a model registered by a previous build.
6868
- name: modelbuildid
69-
value: $[coalesce(variables['MODEL_BUILD_ID'], variables['Build.BuildId'])]
69+
value: $[coalesce(variables['MODEL_BUILD_ID'], variables['Build.BuildId'])]
70+
71+
72+
# Flag to allow rebuilding the AML Environment after it was built for the first time. This enables dependency updates from conda_dependencies.yaml.
73+
# - name: AML_REBUILD_ENVIRONMENT
74+
# value: "false"

ml_service/pipelines/diabetes_regression_build_train_pipeline.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def main():
3333

3434
# Create a reusable Azure ML environment
3535
environment = get_environment(
36-
aml_workspace, e.aml_env_name, create_new=False) # NOQA: E501
37-
36+
aml_workspace, e.aml_env_name, create_new=e.rebuild_env) #
3837
run_config = RunConfiguration()
3938
run_config.environment = environment
4039

ml_service/pipelines/diabetes_regression_build_train_pipeline_with_r.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def main():
3131
# Make sure to include `r-essentials'
3232
# in diabetes_regression/conda_dependencies.yml
3333
environment = get_environment(
34-
aml_workspace, e.aml_env_name, create_new=False) # NOQA: E501
34+
aml_workspace, e.aml_env_name, create_new=e.rebuild_env) # NOQA: E501
3535
run_config = RunConfiguration()
3636
run_config.environment = environment
3737

ml_service/util/env_variables.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def __init__(self):
4646
self._allow_run_cancel = os.environ.get(
4747
"ALLOW_RUN_CANCEL", "true")
4848
self._aml_env_name = os.environ.get("AML_ENV_NAME")
49+
self._rebuild_env = os.environ.get("AML_REBUILD_ENVIRONMENT",
50+
"false").lower().strip() == "true"
4951

5052
@property
5153
def workspace_name(self):
@@ -166,3 +168,7 @@ def allow_run_cancel(self):
166168
@property
167169
def aml_env_name(self):
168170
return self._aml_env_name
171+
172+
@property
173+
def rebuild_env(self):
174+
return self._rebuild_env

0 commit comments

Comments
 (0)