cli_auth = AzureCliAuthentication() ws = Workspace(workspace_name=workspace, subscription_id=subscription_id, resource_group=resource_grp, auth=cli_auth) model_list = Model.list(workspace=ws) model, = (m for m in model_list if m.version == model_version and m.name == model_name) print("Model picked: {} \nModel Description: {} \nModel Version: {}".format( model.name, model.description, model.version)) try: service = AksWebservice(name=service_name, workspace=ws) print("delete " + service_name + " before creating new one") service.delete() except: print(service_name + " does not exist yet") os.chdir("deploy") # Add model name to scorefile with open("scoreSparkTemplate.py") as fr: score = fr.read() score = score.replace("{model_name}", model_name) # with open("scoreSpark.py", "w") as fw: fw.write(score) #inference_config = InferenceConfig(entry_script='scoreSpark.py', runtime='spark-py', conda_file='myenv.yml')
deployment_target=aks_test_cluster) # Show output of the deployment on stdout test_service.wait_for_deployment(show_output=True) print(test_service.state) # Checking status of test web service print("Checking status of AKS Test Deployment") if test_service.state != "Healthy": raise Exception( "Test Deployment on AKS failed with the following status: {} and logs: \n{}" .format(test_service.state, test_service.get_logs())) # Testing AKS web service print("Testing AKS test web service") test_sample = test_functions.get_test_data_sample() print("Test Sample: ", test_sample) test_sample_encoded = bytes(test_sample, encoding='utf8') try: prediction = test_service.run(input_data=test_sample) print(prediction) except Exception as e: result = str(e) logs = test_service.get_logs() test_service.delete() raise Exception( "AKS Test web service is not working as expected: \n{} \nLogs: \n{}". format(result, logs)) # Delete test AKS service after test print("Deleting AKS Test web service after successful test") test_service.delete()