Skip to content

Commit e4a931a

Browse files
jotaylodtzar
authored andcommitted
extending use of SOURCES_DIR_TRAIN variable (#143)
1 parent da60ab1 commit e4a931a

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.pipelines/azdo-ci-build-train.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ stages:
115115
modelSourceType: manualSpec
116116
modelName: '$(MODEL_NAME)'
117117
modelVersion: $(MODEL_VERSION)
118-
inferencePath: '$(Build.SourcesDirectory)/code/scoring/inference_config.yml'
118+
inferencePath: '$(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/scoring/inference_config.yml'
119119
deploymentTarget: ACI
120120
deploymentName: $(ACI_DEPLOYMENT_NAME)
121-
deployConfig: '$(Build.SourcesDirectory)/code/scoring/deployment_config_aci.yml'
121+
deployConfig: '$(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/scoring/deployment_config_aci.yml'
122122
overwriteExistingDeployment: true
123123
- task: AzureCLI@1
124124
displayName: 'Smoke test'
@@ -150,11 +150,11 @@ stages:
150150
modelSourceType: manualSpec
151151
modelName: '$(MODEL_NAME)'
152152
modelVersion: $(MODEL_VERSION)
153-
inferencePath: '$(Build.SourcesDirectory)/code/scoring/inference_config.yml'
153+
inferencePath: '$(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/scoring/inference_config.yml'
154154
deploymentTarget: AKS
155155
aksCluster: $(AKS_COMPUTE_NAME)
156156
deploymentName: $(AKS_DEPLOYMENT_NAME)
157-
deployConfig: '$(Build.SourcesDirectory)/code/scoring/deployment_config_aks.yml'
157+
deployConfig: '$(Build.SourcesDirectory)/$(SOURCES_DIR_TRAIN)/scoring/deployment_config_aks.yml'
158158
overwriteExistingDeployment: true
159159
- task: AzureCLI@1
160160
displayName: 'Smoke test'

code/evaluate/evaluate_model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@
3232
run = Run.get_context()
3333
if (run.id.startswith('OfflineRun')):
3434
from dotenv import load_dotenv
35-
sys.path.append(os.path.abspath("./code/util")) # NOQA: E402
36-
from model_helper import get_model_by_tag
3735
# For local development, set values in this section
3836
load_dotenv()
37+
sources_dir = os.environ.get("SOURCES_DIR_TRAIN")
38+
if (sources_dir is None):
39+
sources_dir = 'code'
40+
path_to_util = os.path.join(".", sources_dir, "util")
41+
sys.path.append(os.path.abspath(path_to_util)) # NOQA: E402
42+
from model_helper import get_model_by_tag
3943
workspace_name = os.environ.get("WORKSPACE_NAME")
4044
experiment_name = os.environ.get("EXPERIMENT_NAME")
4145
resource_group = os.environ.get("RESOURCE_GROUP")

ml_service/pipelines/verify_train_pipeline.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ def main():
1111
run = Run.get_context()
1212
if (run.id.startswith('OfflineRun')):
1313
from dotenv import load_dotenv
14-
sys.path.append(os.path.abspath("./code/util")) # NOQA: E402
15-
from model_helper import get_model_by_tag
1614
# For local development, set values in this section
1715
load_dotenv()
16+
sources_dir = os.environ.get("SOURCES_DIR_TRAIN")
17+
if (sources_dir is None):
18+
sources_dir = 'code'
19+
path_to_util = os.path.join(".", sources_dir, "util")
20+
sys.path.append(os.path.abspath(path_to_util)) # NOQA: E402
21+
from model_helper import get_model_by_tag
1822
workspace_name = os.environ.get("WORKSPACE_NAME")
1923
experiment_name = os.environ.get("EXPERIMENT_NAME")
2024
resource_group = os.environ.get("RESOURCE_GROUP")

ml_service/util/create_scoring_image.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
args = parser.parse_args()
2727

2828
model = Model(ws, name=e.model_name, version=e.model_version)
29-
os.chdir("./code/scoring")
29+
sources_dir = e.sources_dir
30+
if (sources_dir is None):
31+
sources_dir = 'code'
32+
path_to_scoring = os.path.join(".", sources_dir, "scoring")
33+
cwd = os.getcwd()
34+
os.chdir(path_to_scoring)
3035

3136
image_config = ContainerImage.image_configuration(
3237
execution_script=e.score_script,
@@ -40,7 +45,7 @@
4045
name=e.image_name, models=[model], image_config=image_config, workspace=ws
4146
)
4247

43-
os.chdir("../..")
48+
os.chdir(cwd)
4449

4550
image.wait_for_creation(show_output=True)
4651

0 commit comments

Comments
 (0)