0
$\begingroup$

I have an AutoML Pipeline em a need to do an deploy models


train_step = AutoMLStep(name='AutoML_temporal',
    automl_config=automl_config,
    outputs=[metrics_data,model_data],
    enable_default_model_output=False,
    enable_default_metrics_output=False,
    allow_reuse=True)

extremidade_name = PipelineParameter("extremidade_name", default_value="extr001mgm")

deploy_step = PythonScriptStep(script_name="deploy.py",
                                       name="deploy",
                                       allow_reuse=False,
                                       arguments=["--extremidade_name", extremidade_name, "--model_path", model_data],
                                       inputs=[model_data],
                                       compute_target=compute_cluster,
                                       runconfig=aml_run_config)

I created the following script

#%% deploy.py
from azureml.core.model import Model, Dataset
from azureml.core.run import Run, _OfflineRun
from azureml.core import Workspace
from azureml.core.webservice import AksWebservice
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--extremidade_name", required=True)
parser.add_argument("--model_path", required=True)
args = parser.parse_args()

print(f"model_name : {args.extremidade_name}")
print(f"model_path: {args.model_path}")

run = Run.get_context()
ws = Workspace.from_config() if type(run) == _OfflineRun else run.experiment.workspace

from azureml.core.webservice import LocalWebservice, Webservice

deployment_config = AksWebservice.deploy_configuration(cpu_cores = 1, memory_gb = 1)
service = Model.deploy(workspace=ws, name = args.extremidade_name, models=[args.model_path])
service.wait_for_deployment(show_output = True)
print(service.state)

But I need to define inference_config

from azureml.core.environment import Environment
from azureml.core.model import InferenceConfig

env = Environment.get(workspace, "AzureML-Minimal").clone(env_name)

for pip_package in ["scikit-learn"]:
    env.python.conda_dependencies.add_pip_package(pip_package)

inference_config = InferenceConfig(entry_script='script.py',
                                    environment=env)

This is a continuous retraining scenario. How to read a 'path-to-score.py'? How to do I make this script?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.