def upload_file_azureml(ws, ws_id, ws_token, file_path, azure_file_name, endpoint=None):
    """
    Note: this func only works for small datasets...
    :param ws:
    :param df:
    :param df_name:
    :param df_description:
    :return:
    """
    @services.attach((file_path, azure_file_name))
    def f(): pass
    try:
        attachment = services.attach((file_path, azure_file_name))(f)
        result = services.publish(attachment, ws_id, ws_token)
        #result = services.publish(f, WORKSPACE_ID, AUTH_TOKEN)
        print(result)
        print_user_ds(ws)
    except AzureMLConflictHttpError as err:
        msg = 'AzureML is complaining that Dataset already exists: {0}'\
            .format(err)
        print(msg)
    except Exception as err:
        msg = 'Error while trying to upload \'{0}\': {1}'\
            .format(file_path, err)
        print(msg)
    @services.types(a = int, b = int)
    @services.returns(int)
    def dataframe_int(a, b):
        pass

## style 1, define a function and call the publish API explicitly.

# style 1, define a function and publish it with a decorator
@services.publish(TEST_WS, TEST_KEY, endpoint=ENDPOINT)
def myfunc(a, b):
    return [a + b + a, a - b * b, a * b * a, a / b]


# style 2, define a function and call the publish API explicitly.
def myfunc2(a, b):
    return [a + b, a - b, a * b, a / b]

published = services.publish(myfunc2, TEST_WS, TEST_KEY, endpoint=ENDPOINT)




# style 1, kw args
@services.publish(TEST_WS, TEST_KEY, endpoint=ENDPOINT)
def kwargs(**args):
    return args




if hasattr(dataframe, 'service'):

    @services.service(dataframe.service.url, dataframe.service.api_key)
    @services.types(a=int, b=int)
    @services.returns(int)
    def dataframe_int(a, b):
        pass


## style 1, define a function and call the publish API explicitly.


# style 1, define a function and publish it with a decorator
@services.publish(TEST_WS, TEST_KEY, endpoint=ENDPOINT)
def myfunc(a, b):
    return [a + b + a, a - b * b, a * b * a, a / b]


# style 2, define a function and call the publish API explicitly.
def myfunc2(a, b):
    return [a + b, a - b, a * b, a / b]


published = services.publish(myfunc2, TEST_WS, TEST_KEY, endpoint=ENDPOINT)


# style 1, kw args
@services.publish(TEST_WS, TEST_KEY, endpoint=ENDPOINT)
def kwargs(**args):
    return args
Esempio n. 4
0
        "neptune": Neptune.position_at(t),
    }



if __name__ == '__main__':
    # If we're running directly, we want to publish the service and
    # wait for it to finish, then display the URL and the key.

    # TODO: Refactor into own function
    from azureml.services import publish
    from util import wait_for_service
    import webbrowser
    
    print 'You will require an Azure Machine Learning workspace to deploy the service.'
    print
    if raw_input('Create a free workspace now? [y/N] ').startswith('y'):
        print 'Opening web browser. Log in with a Microsoft Account and access your workspace ID'
        print 'and authorization token from Settings.'
        webbrowser.open('https://studio.azureml.net/Home')
    
    workspace_id = raw_input('Please enter your workspace id:')
    auth_token = raw_input('Please enter your authorization token:')
    
    service = publish(get_all_planets, workspace_id, auth_token, files=[('vsop.zip', None)])
    print service.url
    print service.api_key
    wait_for_service(service, 2010, 1, 1)
    print "Press enter to close . . ."
    raw_input()
Esempio n. 5
0


if __name__ == '__main__':
    # If we're running directly, we want to publish the service and
    # wait for it to finish, then display the URL and the key.

    # TODO: Refactor into own function
    from azureml.services import publish
    from util import wait_for_service
    import webbrowser
    
    print 'You will require an Azure Machine Learning workspace to deploy the service.'
    print
    if raw_input('Create a free workspace now? [y/N] ').startswith('y'):
        print 'Opening web browser. Log in with a Microsoft Account and access your workspace ID'
        print 'and authorization token from Settings.'
        webbrowser.open('https://studio.azureml.net/Home')
    
    workspace_id = raw_input('Please enter your workspace id: ')
    auth_token = raw_input('Please enter your authorization token: ')
    
    with open(r'packages\vsop.zip', 'rb') as vsop_file:
        vsop_content = vsop_file.read()
    service = publish(get_all_planets, workspace_id, auth_token, files=[('vsop.zip', vsop_content)])
    print service.url
    print service.api_key
    wait_for_service(service, 2010, 1, 1)
    print "Press enter to close . . ."
    raw_input()