def __deploy_model(self): service_name = self.__args.service_name model = Model(self.__ws, self.__args.model_name) explainer_model = Model(self.__ws, self.__args.explainer_model_name) myenv = Environment.from_conda_specification( name=self.__config.get('DEPLOY', 'ENV_NAME'), file_path=self.__config.get('DEPLOY', 'ENV_FILE_PATH')) inference_config = InferenceConfig( entry_script=self.__config.get('DEPLOY', 'SCORE_PATH'), environment=myenv, source_directory=self.__config.get('DEPLOY', 'DEPENDENCIES_DIRECTORY')) if not self.__args.update_deployment: deployment_config = AciWebservice.deploy_configuration( cpu_cores=self.__config.getint('DEPLOY', 'ACI_CPU'), memory_gb=self.__config.getint('DEPLOY', 'ACI_MEM'), collect_model_data=True, enable_app_insights=True) service = Model.deploy(self.__ws, service_name, [model, explainer_model], inference_config, deployment_config) else: service = AciWebservice(self.__ws, service_name) service.update(models=[model, explainer_model], inference_config=inference_config) service.wait_for_deployment(show_output=True) print(service.state) print(service.get_logs())
auth_enabled=aci_settings["auth_enabled"], ssl_enabled=aci_settings["ssl_enabled"], ssl_cert_pem_file=aci_settings["ssl_cert_pem_file"], ssl_key_pem_file=aci_settings["ssl_key_pem_file"], ssl_cname=aci_settings["ssl_cname"], enable_app_insights=aci_settings["enable_app_insights"], dns_name_label=aci_settings["dns_name_label"]) # Deploying dev web service from image dev_service = Webservice.deploy_from_image(workspace=ws, name=aci_settings["name"], image=image, deployment_config=aci_config) # Show output of the deployment on stdout dev_service.wait_for_deployment(show_output=True) print("State of Service: {}".format(dev_service.state)) # Checking status of web service print("Checking status of ACI Dev Deployment") if dev_service.state != "Healthy": raise Exception( "Dev Deployment on ACI failed with the following status: {} and logs: \n{}" .format(dev_service.state, dev_service.get_logs())) # Testing ACI web service print("Testing ACI web service") test_sample = test_functions.get_test_data_sample() print("Test Sample: ", test_sample) test_sample_encoded = bytes(test_sample, encoding='utf8') try:
print('{}(v.{} [{}]) stored at {} with build log {}'.format( image.name, image.version, image.creation_state, image.image_location, image.image_build_log_uri)) aciconfig = AciWebservice.deploy_configuration( cpu_cores=1, memory_gb=1, tags={'area': "visual object classificiation"}, description='A sample description') aci_service_name = 'aciwebservice' + datetime.datetime.now().strftime('%m%d%H') try: service = AciWebservice(ws, aci_service_name) service.delete() except Exception as e: print(e) pass service = Webservice.deploy_from_image(deployment_config=aciconfig, image=image, name=aci_service_name, workspace=ws) service.wait_for_deployment() # print(service.get_logs()) print('Deployed ACI Webservice: {} \nWebservice Uri: {}'.format( service.name, service.scoring_uri))