当前位置: 首页>>代码示例>>Python>>正文


Python Workspace.get方法代码示例

本文整理汇总了Python中azureml.core.Workspace.get方法的典型用法代码示例。如果您正苦于以下问题:Python Workspace.get方法的具体用法?Python Workspace.get怎么用?Python Workspace.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在azureml.core.Workspace的用法示例。


在下文中一共展示了Workspace.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def create(self, name):
        name = self._get_name(name)
        region = self.ctx.config.get('cluster/region', 'eastus2')
        resource_group = self.ctx.config.get(
            'resource_group', name+'-resources')
        self.ctx.log('Creating %s' % name)

        self.ws = Workspace.create(
            name=name,
            subscription_id=self.credentials.subscription_id,
            resource_group=resource_group,
            create_resource_group=True,
            location=region,
            auth=self.credentials.get_serviceprincipal_auth())
        self._select(name)
        self.ctx.log('%s created' % name)
        return {'created': name} 
开发者ID:augerai,项目名称:a2ml,代码行数:19,代码来源:project.py

示例2: run

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def run(model_path, model_name, tenant_id, service_principal_id,
        service_principal_password, subscription_id, resource_group, workspace, tags):
    auth_args = {
        'tenant_id': tenant_id,
        'service_principal_id': service_principal_id,
        'service_principal_password': service_principal_password
    }

    ws_args = {
        'auth': ServicePrincipalAuthentication(**auth_args),
        'subscription_id': subscription_id,
        'resource_group': resource_group
    }

    ws = Workspace.get(workspace, **ws_args)

    print(ws.get_details())

    print('\nSaving model {} to {}'.format(model_path, model_name))

    # Model Path needs to be relative
    model_path = relpath(model_path, '.')

    model = Model.register(ws, model_name=model_name, model_path=model_path, tags=tags)
    print('Done!') 
开发者ID:aronchick,项目名称:kubeflow-and-mlops,代码行数:27,代码来源:register.py

示例3: call_web_service

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def call_web_service(e, service_type, service_name):
    aml_workspace = Workspace.get(
        name=e.workspace_name,
        subscription_id=e.subscription_id,
        resource_group=e.resource_group
    )
    print("Fetching service")
    headers = {}
    if service_type == "ACI":
        service = AciWebservice(aml_workspace, service_name)
    else:
        service = AksWebservice(aml_workspace, service_name)
    if service.auth_enabled:
        service_keys = service.get_keys()
        headers['Authorization'] = 'Bearer ' + service_keys[0]
    print("Testing service")
    print(". url: %s" % service.scoring_uri)
    output = call_web_app(service.scoring_uri, headers)

    return output 
开发者ID:microsoft,项目名称:MLOpsPython,代码行数:22,代码来源:smoke_test_scoring_service.py

示例4: get_pipeline

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def get_pipeline(pipeline_id, ws: Workspace, env: Env):
    if pipeline_id is not None:
        scoringpipeline = PublishedPipeline.get(ws, pipeline_id)
    else:
        pipelines = PublishedPipeline.list(ws)
        scoringpipelinelist = [
            pl for pl in pipelines if pl.name == env.scoring_pipeline_name
        ]  # noqa E501

        if scoringpipelinelist.count == 0:
            raise Exception(
                "No pipeline found matching name:{}".format(env.scoring_pipeline_name)  # NOQA: E501
            )
        else:
            # latest published
            scoringpipeline = scoringpipelinelist[0]

    return scoringpipeline 
开发者ID:microsoft,项目名称:MLOpsPython,代码行数:20,代码来源:run_parallel_batchscore_pipeline.py

示例5: get_workspace

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def get_workspace(
        name: str,
        resource_group: str,
        subscription_id: str,
        tenant_id: str,
        app_id: str,
        app_secret: str):
    service_principal = ServicePrincipalAuthentication(
        tenant_id=tenant_id,
        service_principal_id=app_id,
        service_principal_password=app_secret)

    try:
        aml_workspace = Workspace.get(
            name=name,
            subscription_id=subscription_id,
            resource_group=resource_group,
            auth=service_principal)

        return aml_workspace
    except Exception as caught_exception:
        print("Error while retrieving Workspace...")
        print(str(caught_exception))
        sys.exit(1) 
开发者ID:Azure-Samples,项目名称:MLOpsDatabricks,代码行数:26,代码来源:workspace.py

示例6: build_image

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def build_image(model_uri, workspace_name, subscription_id, image_name, model_name,
                mlflow_home, description, tags):
    """
    Register an MLflow model with Azure ML and build an Azure ML ContainerImage for deployment.
    The resulting image can be deployed as a web service to Azure Container Instances (ACI) or
    Azure Kubernetes Service (AKS).

    The resulting Azure ML ContainerImage will contain a webserver that processes model queries.
    For information about the input data formats accepted by this webserver, see the following
    documentation: https://www.mlflow.org/docs/latest/models.html#azureml-deployment.
    """
    # The Azure ML SDK is only compatible with Python 3. However, this CLI should still be
    # accessible for inspection rom Python 2. Therefore, we will only import from the SDK
    # upon command invocation.
    # pylint: disable=import-error
    from azureml.core import Workspace

    workspace = Workspace.get(name=workspace_name, subscription_id=subscription_id)
    if tags is not None:
        tags = json.loads(tags)
    mlflow.azureml.build_image(
            model_uri=model_uri, workspace=workspace, image_name=image_name, model_name=model_name,
            mlflow_home=mlflow_home, description=description, tags=tags, synchronous=True) 
开发者ID:mlflow,项目名称:mlflow,代码行数:25,代码来源:cli.py

示例7: get_output_files

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def get_output_files(run, output_path, file_names=None):
    """
    Method to get the output files from an AzureML output directory.

    Args:
        file_names(list): Names of the files to download.
        run(azureml.core.run.Run): Run object of the run.
        output_path(str): Path to download the output files.

    Returns: None

    """
    os.makedirs(output_path, exist_ok=True)

    if file_names is None:
        file_names = run.get_file_names()

    for f in file_names:
        dest = os.path.join(output_path, f.split("/")[-1])
        print("Downloading file {} to {}...".format(f, dest))
        run.download_file(f, dest) 
开发者ID:microsoft,项目名称:forecasting,代码行数:23,代码来源:azureml_utils.py

示例8: delete

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def delete(self, name):
        name = self._get_name(name)
        ws = Workspace.get(
            name, 
            subscription_id=self.credentials.subscription_id, 
            auth=self.credentials.get_serviceprincipal_auth())
        self.ctx.log('Deleting %s' % name)
        ws.delete(delete_dependent_resources=True, no_wait=False)
        self._select(None)
        self.ctx.log('%s deleted' % name)
        return {'deleted': name} 
开发者ID:augerai,项目名称:a2ml,代码行数:13,代码来源:project.py

示例9: _get_name

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def _get_name(self, name = None):
        if name is None:
            name =  self.ctx.config.get('name', None)
        if name is None:
            raise AzureException('Please provide project name...')
        return name 
开发者ID:augerai,项目名称:a2ml,代码行数:8,代码来源:project.py

示例10: _get_ws

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def _get_ws(self, name = None, create_if_not_exist = False):
        name = self._get_name(name)
        try:
            self.ws = Workspace.get(
                name, 
                subscription_id=self.credentials.subscription_id, 
                auth=self.credentials.get_serviceprincipal_auth())
        except Exception as e:
            if create_if_not_exist:
                self.create(name)
            else:
                raise e
        return self.ws 
开发者ID:augerai,项目名称:a2ml,代码行数:15,代码来源:project.py

示例11: run_batchscore_pipeline

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def run_batchscore_pipeline():
    try:
        env = Env()

        args = parse_args()

        aml_workspace = Workspace.get(
            name=env.workspace_name,
            subscription_id=env.subscription_id,
            resource_group=env.resource_group,
        )

        scoringpipeline = get_pipeline(args.pipeline_id, aml_workspace, env)

        experiment = Experiment(workspace=aml_workspace, name=env.experiment_name)  # NOQA: E501

        run = experiment.submit(
            scoringpipeline,
            pipeline_parameters={
                "model_name": env.model_name,
                "model_version": env.model_version,
                "model_tag_name": " ",
                "model_tag_value": " ",
            },
        )

        run.wait_for_completion(show_output=True)

        if run.get_status() == "Finished":
            copy_output(list(run.get_steps())[0].id, env)

    except Exception as ex:
        print("Error: {}".format(ex)) 
开发者ID:microsoft,项目名称:MLOpsPython,代码行数:35,代码来源:run_parallel_batchscore_pipeline.py

示例12: get_workspace

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def get_workspace():
    dotenv.load_dotenv()
    workspace_name = os.environ.get("WORKSPACE")
    resource_group = os.environ.get("RESOURCE_GROUP")
    subscription_id = os.environ.get("SUBSCRIPTION_ID")
    tenant_id = os.environ.get("TENANT_ID")
    app_id = os.environ.get("SP_APP_ID")
    app_secret = os.environ.get("SP_APP_SECRET")

    service_principal = ServicePrincipalAuthentication(
        tenant_id=tenant_id,
        service_principal_id=app_id,
        service_principal_password=app_secret)

    try:
        aml_workspace = Workspace.get(
            name=workspace_name,
            subscription_id=subscription_id,
            resource_group=resource_group,
            auth=service_principal)

        return aml_workspace
    except Exception as caught_exception:
        print("Error while retrieving Workspace...")
        print(str(caught_exception))
        sys.exit(1) 
开发者ID:rsethur,项目名称:MLOps,代码行数:28,代码来源:AzureMLUtils.py

示例13: __init__

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def __init__(self):
        self.mocks = {
            "register_model": mock.patch("azureml.core.model.Model.register"),
            "get_model_path": mock.patch("azureml.core.model.Model.get_model_path"),
            "create_image": mock.patch("azureml.core.Image.create"),
            "deploy": mock.patch("azureml.core.model.Model.deploy"),
            "load_workspace": mock.patch("azureml.core.Workspace.get"),
        } 
开发者ID:mlflow,项目名称:mlflow,代码行数:10,代码来源:test_image_creation.py

示例14: get_azure_workspace

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def get_azure_workspace():
    # pylint: disable=import-error
    from azureml.core import Workspace
    return Workspace.get("test_workspace") 
开发者ID:mlflow,项目名称:mlflow,代码行数:6,代码来源:test_image_creation.py

示例15: __init__

# 需要导入模块: from azureml.core import Workspace [as 别名]
# 或者: from azureml.core.Workspace import get [as 别名]
def __init__(self):
        self.mocks = {
            "register_model": mock.patch("azureml.core.model.Model.register"),
            "get_model_path": mock.patch("azureml.core.model.Model.get_model_path"),
            "model_deploy": mock.patch("azureml.core.model.Model.deploy"),
            "load_workspace": mock.patch("azureml.core.Workspace.get"),
        } 
开发者ID:mlflow,项目名称:mlflow,代码行数:9,代码来源:test_deploy.py


注:本文中的azureml.core.Workspace.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。