Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to reuse an existing Endpoint in pipeline? #400

Closed
MMichael-S opened this issue Mar 22, 2022 · 3 comments
Closed

How to reuse an existing Endpoint in pipeline? #400

MMichael-S opened this issue Mar 22, 2022 · 3 comments

Comments

@MMichael-S
Copy link

Hi Experts

Expected Behavior

Hope to reuse an existing endpoint in pipeline.

Also see that google_cloud_pipeline_components.v1.endpoint has only EndpointCreateOp method.
https://google-cloud-pipeline-components.readthedocs.io/en/google-cloud-pipeline-components-1.0.0/google_cloud_pipeline_components.v1.endpoint.html

Is there a way to reuse an existing Endpoint? And how to reuse it? This will saves costs.

Actual Behavior

Have to create a new Endpoint in the pipeline.
See that the EndpointCreateOp step is included in all the sample code.

 endpoint_op = EndpointCreateOp(
     project=project,
     location=region,
     display_name="train-automl-flowers",
 )

 ModelDeployOp(
     model=training_run_task.outputs["model"],
     endpoint=endpoint_op.outputs["endpoint"],
     automatic_resources_min_replica_count=1,
     automatic_resources_max_replica_count=1,
 )

Steps to Reproduce the Problem

N/A

Specifications

  • Version:
    google-cloud-pipeline-components-1.0.0
  • Platform:
    Google Cloud Vertex AI
@andrewferlitsch
Copy link
Contributor

This does appear to be a limitation the prebuilt components. You could then write your own python component, something like:

@component()
def get_endpoint(resource_name: str,
endpoint: Output[Artifact]
)
endpoint = aiplatform.Endpoint(endpoint_name=resource_name)

@MMichael-S
Copy link
Author

MMichael-S commented Mar 23, 2022

@andrewferlitsch
Thank you very much.
We have done in the same way by using customized components to import the existed endpoint.

Code as following, for someone who need the reference:

from google_cloud_pipeline_components.types import artifact_types
from kfp.v2.components import importer_node


endpoint = importer_node.importer(
    artifact_uri="https://us-central1-aiplatform.googleapis.com/v1/projects/xxxxxxxx/locations/us-central1/endpoints/xxxxxx",
    artifact_class=artifact_types.VertexEndpoint,
    metadata={
        "resourceName": "projects/xxxx/locations/us-central1/endpoints/xxxxx"
    }
)
...
ModelDeployOp(
        model=training_run_task.outputs["model"],
        endpoint=endpoint.outputs['artifact'],
        automatic_resources_min_replica_count=1,
        automatic_resources_max_replica_count=1,
    )

@andrewferlitsch
Copy link
Contributor

Thanks @MMichael-S for posting example using the importer_node method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants