Beispiel #1
0
def add_endpoint(ws: Workspace, pipeline: PublishedPipeline,
                 endpoint_name: str) -> PipelineEndpoint:
    endpoint_list = [p.name for p in PipelineEndpoint.list(ws)]
    endpoint = None
    # endpoint does not exist so add
    if endpoint_name in endpoint_list:
        endpoint = PipelineEndpoint.get(workspace=ws, name=endpoint_name)
        endpoint.add_default(published_pipeline)
    else:
        endpoint = PipelineEndpoint.publish(
            workspace=ws,
            name=endpoint_name,
            pipeline=published_pipeline,
            description="Seer Pipeline Endpoint")
    return endpoint
Beispiel #2
0
def clean_azml_workspace(ctx):
    """
    [WARNING] Only use in test-only workspace. Remove or disable all compute clusters, published pipelines, published pipeline endpoints and schedules from Azure ML workspace.
    """

    ws = Workspace.from_config()

    # remove compute clusters
    for _, compute in ws.compute_targets.items():
        if not compute.provisioning_state == "Deleting":
            compute.delete()

    # deactivate schedules
    for s in Schedule.list(ws):
        s.disable()

    # remove pipeline endpoints
    for pe in PipelineEndpoint.list(ws):
        pe.disable()

    # remove pipelines
    for p in PublishedPipeline.list(ws):
        p.disable()
from azureml.pipeline.core import Pipeline, PublishedPipeline, PipelineEndpoint

print(f'Azure ML SDK version: {azureml.core.VERSION}')

endpoint_name = "training-pipeline-endpoint"
pipeline_id = os.getenv('PIPELINE_ID')

# Connect to the workspace
ws = Workspace.from_config()
print(f'WS name: {ws.name}')
print(f'Region: {ws.location}')
print(f'Subscription id: {ws.subscription_id}')
print(f'Resource group: {ws.resource_group}')

print(f'Pipeline ID: {pipeline_id}')
published_pipeline = PublishedPipeline.get(workspace=ws, id=pipeline_id)
print(f'Published Pipeline: {published_pipeline}')

# Check if PipelineEndpoint already exists
if any(pe.name == endpoint_name for pe in PipelineEndpoint.list(ws)):
    print(f'Pipeline Endpoint with name {endpoint_name} already exists, will add pipeline to it')
    pipeline_endpoint = PipelineEndpoint.get(workspace=ws, name=endpoint_name)
    pipeline_endpoint.add(published_pipeline)
    # Set it to default, as we already tested it beforehand!
    pipeline_endpoint.set_default(published_pipeline)
else:
    print(f'Will create Pipeline Endpoint with name {endpoint_name}')
    pipeline_endpoint = PipelineEndpoint.publish(workspace=ws,
                                                name=endpoint_name,
                                                pipeline=published_pipeline,
                                                description="New Training Pipeline Endpoint")