def test_service(service: AksWebservice,
                 container: str,
                 blob: str,
                 write_logs: bool = True) -> None:
    if write_logs:
        logs = service.get_logs()
        with open("logs.txt", "w") as fp:
            fp.write(logs)
    data = {"container": container, "blob": blob}
    data_raw = bytes(json.dumps({"data": data}), encoding="utf8")
    print("Testing service: {0}".format(service.name))
    print("Container: {0}, blob: {1}".format(container, blob))
    ping = time.time()
    response = service.run(input_data=data_raw)
    print("Elapsed time: {0:.5f}".format(time.time() - ping))
    print("Response: {0}".format(response))
예제 #2
0
    test_service = Webservice.deploy_from_image(
        workspace=ws,
        name=aks_service_settings["name"],
        image=image,
        deployment_config=aks_config,
        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{}".
예제 #3
0
# Print the predicted class for each case.
for i in range(len(x_new)):
    print (x_new[i]), predictions[i] )


#check service state
from azureml.core.webservice import AksWebservice

# Get the deployed service
service = AksWebservice(name='classifier-service', workspace=ws)

# Check its state
print(service.state)   

#review service logs
print(service.get_logs())


#deploy to local container to diagnose probs
from azureml.core.webservice import LocalWebservice

deployment_config = LocalWebservice.deploy_configuration(port=8890)
service = Model.deploy(ws, 'test-svc', [model], inference_config, deployment_config)

#test deployed service
print(service.run(input_data = json_data))

#troubleshoot issues by changing scoring file
#then reload wo having to redeploy
service.reload()
print(service.run(input_data = json_data))
예제 #4
0
    # Deploying prod web service from image
    prod_service = Webservice.deploy_from_image(workspace=ws,
                                                name=aks_service_settings["name"],
                                                image=image,
                                                deployment_config=aks_config,
                                                deployment_target=aks_prod_cluster)
# Show output of the deployment on stdout
prod_service.wait_for_deployment(show_output=True)
print(prod_service.state)

# Checking status of prod web service
print("Checking status of AKS Prod Deployment")
if prod_service.state != "Healthy":
    raise Exception(
        "Prod Deployment on AKS failed with the following status: {} and logs: \n{}".format(
            prod_service.state, prod_service.get_logs()
        )
    )

# Testing AKS web service
print("Testing AKS prod 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 = prod_service.run(input_data=test_sample)
    print(prediction)
except Exception as e:
    result = str(e)
    logs = prod_service.get_logs()
    raise Exception("AKS Prod web service is not working as expected: \n{} \nLogs: \n{}".format(result, logs))
예제 #5
0
    prod_service = Webservice.deploy_from_image(
        workspace=ws,
        name=aks_service_settings["name"],
        image=image,
        deployment_config=aks_config,
        deployment_target=aks_prod_cluster)
# Show output of the deployment on stdout
prod_service.wait_for_deployment(show_output=True)
print(prod_service.state)

# Checking status of prod web service
print("Checking status of AKS Prod Deployment")
if prod_service.state != "Healthy":
    raise Exception(
        "Prod Deployment on AKS failed with the following status: {} and logs: \n{}"
        .format(prod_service.state, prod_service.get_logs()))

# Testing AKS web service
print("Testing AKS prod 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 = prod_service.run(input_data=test_sample)
    print(prediction)
except Exception as e:
    result = str(e)
    logs = prod_service.get_logs()
    raise Exception(
        "AKS Prod web service is not working as expected: \n{} \nLogs: \n{}".
        format(result, logs))
import json
import pickle
import numpy as np
import pandas as pd
from azureml.core.workspace import Workspace
import azureml.train.automl
from sklearn.externals import joblib
from azureml.core.model import Model

ws = Workspace.from_config('./config.json')

from azureml.core.webservice import Webservice, AciWebservice, AksWebservice
# service = AciWebservice(ws, "sentiment-scorer-korean")
# service = AksWebservice(ws, "sentiment-scorer-korean-aks")
service = AksWebservice(ws, "sentiment-scorer-korean-aks-prob")

service.get_logs()