-
Notifications
You must be signed in to change notification settings - Fork 24
/
submit_aml_run.py
43 lines (32 loc) · 1.24 KB
/
submit_aml_run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Script which submits other scripts to be run in Azure Machine Learning."""
import argparse
import os
from azureml.core import (
Environment,
Experiment,
ScriptRunConfig,
Workspace
)
def _parse_args():
parser = argparse.ArgumentParser("Azure ML Experiment Runner")
parser.add_argument("name", help="Name of the experiment")
parser.add_argument("compute", help="Name of the compute target")
parser.add_argument("script_path", help="Path to the script to run")
parser.add_argument("script_args", help="The script args")
return parser.parse_args()
def _main():
args = _parse_args()
ws = Workspace.from_config()
experiment = Experiment(workspace=ws, name=args.name)
env_path = os.path.join("azureml", "aml_env.yml")
environment = Environment.from_conda_specification("training", env_path)
config = ScriptRunConfig(source_directory=".",
script=args.script_path,
arguments=args.script_args.split(),
compute_target=args.compute,
environment=environment)
run = experiment.submit(config)
aml_url = run.get_portal_url()
print(aml_url)
if __name__ == "__main__":
_main()