Batch endpoints decouples the interface (endpoint) from the actual implementation (deployment) and allow the user to decide which deployment serves the default implementation of the endpoint. Pipeline component deployments in batch endpoints allow users to deploy pipeline components instead of pipelines, which make a better use of reusable assets for those organizations looking to streamline their MLOps practice.
The following table shows a comparison of each of the concepts:
Batch endpoints don't deploy pipelines but pipeline components. Components propose a more reliable way for having source control of the assets that are being deployed under an endpoint. We can convert any pipeline definition into a pipeline component as follows:
pipeline_component = pipeline().component
As a best practice, we recommend registering pipeline components so you can keep versioning of them in a centralized way inside the workspace or even the shared registries.
ml_client.components.create(pipeline_component)
Then, we need to create the endpoint hosting all the pipeline deployments:
endpoint_name = "PipelineEndpointTest"
endpoint = BatchEndpoint(
name=endpoint_name,
description="A hello world endpoint for component deployments",
)
ml_client.batch_endpoints.begin_create_or_update(endpoint)
Create a deployment for the pipeline component:
deployment_name = "hello-batch-dpl"
deployment = BatchPipelineComponentDeployment(
name=deployment_name,
description="A hello world deployment with a single step.",
endpoint_name=endpoint.name,
component=pipeline_component
)
ml_client.batch_deployments.begin_create_or_update(deployment)
In batch endpoints, deployments aren't versioned. However, you can deploy multiple pipeline components versions under the same endpoint. In this sense, each pipeline version in v1 corresponds to a different pipeline component version and its corresponding deployment under the endpoint.
Then, you can deploy a specific deployment running under the endpoint if that deployment runs the version yo're interested in.
The following code list all the endpoints existing in the workspace:
all_endpoints = ml_client.batch_endpoints.list()
However, keep in mind that batch endpoints can host deployments operationalizing either pipelines or models. If you want to get a list of all the deployments that host pipelines, you can do as follows:
all_deployments = []
for endpoint in all_endpoints:
all_deployments.extend(ml_client.batch_deployments.list(endpoint_name=endpoint.name))
all_pipeline_deployments = filter(all_endpoints, lamdba x: x is BatchPipelineComponentDeployment)
Using the REST API
You can create jobs from the endpoints by using the REST API of the invocation URL. See the following examples to see how invocation has changed from v1 to v2.
Batch endpoints support multiple inputs types. The following example shows how to indicate two different inputs of type string and numeric. See Create jobs and input data for batch endpoints (REST) for more detailed examples: