Created
May 7, 2020 14:10
-
-
Save surajkota/1ca7923491aad99e6bdc7cc878732d0b to your computer and use it in GitHub Desktop.
Create a hosting endpoint on SageMaker using Kubeflow Pipeline components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kfp | |
from kfp import components | |
from kfp import dsl | |
from kfp.aws import use_aws_secret | |
# Replace the argument with path to the component file or use load_component_from_url() method | |
sagemaker_model_op = components.load_component_from_file("../../model/component.yaml") | |
# Replace the argument with path to the component file or use load_component_from_url() method | |
sagemaker_deploy_op = components.load_component_from_file("../../deploy/component.yaml") | |
@dsl.pipeline( | |
name="Create Hosting Endpoint in SageMaker", | |
description="Uses SageMaker model and deploy component", | |
) | |
def create_endpoint_pipeline( | |
region="", | |
image="", | |
model_name="", | |
endpoint_config_name="", | |
endpoint_name="", | |
model_artifact_url="", | |
instance_type_1="", | |
role="", | |
): | |
create_model = sagemaker_model_op( | |
region=region, | |
model_name=model_name, | |
image=image, | |
model_artifact_url=model_artifact_url, | |
role=role | |
).apply(use_aws_secret("aws-secret", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY")) | |
sagemaker_deploy_op( | |
region=region, | |
endpoint_config_name=endpoint_config_name, | |
endpoint_name=endpoint_name, | |
model_name_1=create_model.output, | |
instance_type_1=instance_type_1 | |
).apply(use_aws_secret("aws-secret", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY")) | |
if __name__ == "__main__": | |
kfp.compiler.Compiler().compile( | |
create_endpoint_pipeline, "SageMaker_hosting_pipeline" + ".yaml" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment