Пример #1
0
def deploy_service(ws, model, inference_config, service_name, compute_target):
    tags = {'model': '{}:{}'.format(model.name, model.version)}

    try:
        service = Webservice(ws, service_name)
        print("Service {} exists, update it".format(service_name))
        service.update(models=[model],
                       inference_config=inference_config,
                       tags=tags)
    except Exception:
        print('deploy a new service {}'.format(service_name))
        deployment_config = AksWebservice.deploy_configuration(
            cpu_cores=1,
            memory_gb=2,
            tags=tags,
            collect_model_data=True,
            enable_app_insights=True)
        service = Model.deploy(ws, service_name, [model], inference_config,
                               deployment_config, compute_target)

    service.wait_for_deployment(show_output=True)

    if service.auth_enabled:
        token = service.get_keys()[0]
    elif service.token_auth_enabled:
        token = service.get_token()[0]

    return service.scoring_uri, token
Пример #2
0
from azureml.core.webservice import Webservice
from azureml.core import Workspace

# get scoring url
workspace = Workspace.from_config()
service_name = 'arxiv-nmt-service'
service = Webservice(workspace, name=service_name)
scoring_url = service.scoring_uri

# set headers
headers = {'Content-Type': 'application/json'}

if service.auth_enabled:
    headers['Authorization'] = 'Bearer '+ service.get_keys()[0]
elif service.token_auth_enabled:
    headers['Authorization'] = 'Bearer '+ service.get_token()[0]

print(headers)

# generate dummy example
test_abstract = 'The groups $\gamma_{n,s}$ are defined in terms of homotopy ' \
'equivalences of certain graphs, and are natural generalisations ' \
'of $Out(Fn)$ and $Aut(Fn)$. They have appeared frequently in ' \
'the study of free group automorphisms, for example in proofs of ' \
'homological stability in [8,9] and in the proof that $Out(Fn)$ ' \
'is a virtual duality group in [1]. More recently, in [5], their ' \
'cohomology $H_i(\Gamma_{n,s})$, over a field of characteristic zero, ' \
'was computed in ranks $n=1,2$ giving new constructions of unstable ' \
'homology classes of $Out(Fn)$ and $Aut(Fn)$. In this paper we show ' \
'that, for fixed $i$ and $n$, this cohomology $H_iGammans$ forms a ' \
'finitely generated FI-module of stability degree $n$ and weight $i$, ' \