我目前正在与Azure机器学习服务一起从事机器学习项目。但是我发现了一个问题,我无法将新的Docker映像更新到现有的Web服务(我希望使用与运行we service相同的URL)。
我已经阅读了文档,但是并没有真正告诉我如何更新(文档链接:https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-deploy-and-where)。 该文档说,我们必须将update()与image = new-image一起使用。
from azureml.core.webservice import Webservice
service_name = 'aci-mnist-3
# Retrieve existing service
service = Webservice(name = service_name, workspace = ws)
# Update the image used by the service
service.update(image = new-image)
print(service.state)
但是没有描述new-image
的来源。
有人知道如何解决这个问题吗?
谢谢
答案 0 :(得分:2)
我同意,文档在这一部分上可能会更加清晰。 new-image
是一个图像对象,您应该将其传递到update()
函数中。如果您只是创建图像,则可能已经在变量中包含了该对象,则只需传递它即可。如果没有,那么您可以使用
from azureml.core.image.image import Image
new_image = Image(ws, image_name)
其中ws
是您的工作区对象,而image_name
是一个字符串,其中包含您要获取的图像的名称。然后,您继续以{p>
update()
中找到更多信息。
编辑:
上面的from azureml.core.webservice import Webservice
service_name = 'aci-mnist-3
# Retrieve existing service
service = Webservice(name = service_name, workspace = ws)
# Update the image used by the service
service.update(image = new_image) # Note that dash isn't supported in variable names
print(service.state)
和Image
类都是抽象父类。
对于Webservice
对象,您应该根据情况使用以下类之一:
Image
ContainerImage
(请参阅文档中的Image package)。
对于UnknownImage
对象,应根据情况使用以下类之一:
Webservice
AciWebservice
AksWebservice
(请参阅文档中的Webservice package)。