使用 azuremlsdk 的 azure 机器学习 Web 服务的分数/条目文件

问题描述

看着this example

library(azuremlsdk)
library(jsonlite)

ws <- load_workspace_from_config()

# Register the model
model <- register_model(ws,model_path = "model.rds",model_name = "model.rds")

# Create environment
r_env <- r_environment(name = "r_env")

# Create inference config
inference_config <- inference_config(
  entry_script = "score.R",source_directory = ".",environment = r_env)

# Create ACI deployment config
deployment_config <- aci_webservice_deployment_config(cpu_cores = 1,memory_gb = 1)

# Deploy the web service
service_name <- paste0('aciwebservice-',sample(1:100,1,replace=TRUE))
service <- deploy_model(ws,service_name,list(model),inference_config,deployment_config)
wait_for_deployment(service,show_output = TRUE)

会不会是score.R 必须上传到Azure 环境并且不像在开发机器上那样是本地的?我目前的想法是,那个 source_directory 。指的是本地系统(即在开发机器上)?

解决方法

source_directory 指的是本地系统(即在开发机器上)?

正确。而 entry_script 应该是在 source_directory 中找到的文件。如果 entry_script 引用其他文件,它们也应该在 source_directory 中。 SDK 将处理对您的源目录进行快照并将其上传到远程计算。

因此,建议您将要在远程计算上运行的代码与项目的其余部分隔离,如下所示。 source_directory=./scoring 中的 deploy-to-aci.R

dir/
    deploy-to-aci.R
    scoring/
        score.R
    sensitive_data.csv