def upload_pipeline_artefact_registry()

in python/pipelines/pipeline_ops.py [0:0]


def upload_pipeline_artefact_registry(
        template_path: str,
        project_id: str,
        region: str,
        repo_name: str,
        tags: list = None,
        description: str = None) -> str:
    """
    This function uploads a pipeline YAML file to the Artifact Registry.

    Args:
        template_path: The path to the pipeline YAML file.
        project_id: The ID of the project that contains the pipeline.
        region: The location of the pipeline.
        repo_name: The name of the repository to upload the pipeline to.
        tags: A list of tags to apply to the pipeline.
        description: A description of the pipeline.

    Returns:
        The name of the uploaded pipeline.

    Raises:
        Exception: If an error occurs while uploading the pipeline.
    """
    logging.info(f"Uploading pipeline to {region}-kfp.pkg.dev/{project_id}/{repo_name}")

    host = f"https://{region}-kfp.pkg.dev/{project_id}/{repo_name}"
    client = RegistryClient(host=host)
    response = client.upload_pipeline(
        file_name=template_path,
        tags=tags,
        extra_headers={"description": description})
    logging.info(f"Pipeline uploaded : {host}")
    logging.info(response)
    return response[0]