added yaml support for pipelines

This commit is contained in:
Marvin Buss 2020-04-03 01:41:30 +02:00
Родитель 28b526a266
Коммит e2e9217bec
1 изменённых файлов: 44 добавлений и 31 удалений

Просмотреть файл

@ -4,7 +4,7 @@ import importlib
from azureml.core import Workspace, Experiment
from azureml.core.authentication import ServicePrincipalAuthentication
from azureml.pipeline.core import PipelineRun
from azureml.pipeline.core import PipelineRun, Pipeline
from azureml.exceptions import AuthenticationException, ProjectSystemException, AzureMLException, UserErrorException
from adal.adal_error import AdalError
from msrest.exceptions import AuthenticationError
@ -97,38 +97,51 @@ def main():
print(f"::error::Could not create an experiment with the specified name {experiment_name}: {exception}")
raise AMLExperimentConfigurationException(f"Could not create an experiment with the specified name {experiment_name}: {exception}")
# Load module
print("::debug::Loading module to receive experiment config")
run_config_file_path = parameters.get("run_config_file_path", "code/train/run_config.py")
run_config_file_function_name = parameters.get("run_config_file_function_name", "main")
if parameters.get("pipeline_yaml", None) is not None:
# Load pipeline yaml definition
print("::debug::Loading pipeline yaml definition")
try:
run_config = Pipeline.load_yaml(
workspace=ws,
filename=parameters.get("pipeline_yaml", None)
)
except Exception as exception:
pipeline_yaml_path = parameters.get("pipeline_yaml", None)
print(f"::error::Error when loading pipeline yaml definition your repository (Path: /{pipeline_yaml_path}): {exception}")
raise AMLExperimentConfigurationException(f"Error when loading pipeline yaml definition your repository (Path: /{pipeline_yaml_path}): {exception}")
else:
# Load module
print("::debug::Loading module to receive experiment config")
run_config_file_path = parameters.get("run_config_file_path", "code/train/run_config.py")
run_config_file_function_name = parameters.get("run_config_file_function_name", "main")
print("::debug::Importing module")
run_config_file_path = f"{run_config_file_path}.py" if not run_config_file_path.endswith(".py") else run_config_file_path
try:
run_config_spec = importlib.util.spec_from_file_location(
name="runmodule",
location=run_config_file_path
)
run_config_module = importlib.util.module_from_spec(spec=run_config_spec)
run_config_spec.loader.exec_module(run_config_module)
run_config_function = getattr(run_config_module, run_config_file_function_name, None)
except ModuleNotFoundError as exception:
print(f"::error::Could not load python script in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
raise AMLExperimentConfigurationException(f"Could not load python script in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
except FileNotFoundError as exception:
print(f"::error::Could not load python script or function in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
raise AMLExperimentConfigurationException(f"Could not load python script or function in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
except AttributeError as exception:
print(f"::error::Could not load python script or function in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
raise AMLExperimentConfigurationException(f"Could not load python script or function in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
print("::debug::Importing module")
run_config_file_path = f"{run_config_file_path}.py" if not run_config_file_path.endswith(".py") else run_config_file_path
try:
run_config_spec = importlib.util.spec_from_file_location(
name="runmodule",
location=run_config_file_path
)
run_config_module = importlib.util.module_from_spec(spec=run_config_spec)
run_config_spec.loader.exec_module(run_config_module)
run_config_function = getattr(run_config_module, run_config_file_function_name, None)
except ModuleNotFoundError as exception:
print(f"::error::Could not load python script in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
raise AMLExperimentConfigurationException(f"Could not load python script in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
except FileNotFoundError as exception:
print(f"::error::Could not load python script or function in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
raise AMLExperimentConfigurationException(f"Could not load python script or function in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
except AttributeError as exception:
print(f"::error::Could not load python script or function in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
raise AMLExperimentConfigurationException(f"Could not load python script or function in your repository which defines the experiment config (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
# Load experiment config
print("::debug::Loading experiment config")
try:
run_config = run_config_function(ws)
except TypeError as exception:
print(f"::error::Could not load experiment config from your module (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
raise AMLExperimentConfigurationException(f"Could not load experiment config from your module (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
# Load experiment config
print("::debug::Loading experiment config")
try:
run_config = run_config_function(ws)
except TypeError as exception:
print(f"::error::Could not load experiment config from your module (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
raise AMLExperimentConfigurationException(f"Could not load experiment config from your module (Script: /{run_config_file_path}, Function: {run_config_file_function_name}()): {exception}")
# Submit experiment config
print("::debug::Submitting experiment config")