name: evaluated_annotation_import
description: |
  Imports evaluated annotations to an existing Vertex model with ModelService.BatchImportEvaluatedAnnotations
  Evaluated Annotation inputs must be provided. ErrorAnalysisAnnotation, EvaluatedAnnotationExplanation are optional.
  Args:
    model (google.VertexModel):
      Vertex model resource that will be the parent resource of the uploaded evaluation.
    evaluated_annotation_output_uri (str):
      Path of evaluated annotations generated from EvaluatedAnnotation component.
    evaluation_importer_gcp_resources (str):
      GCP resource created by ModelEvaluationImporter comopnent.
      Specify this parameter in KFP pipeline by passing output from the ModelEvaluationImporter:
        `evaluation_importer_gcp_resources=eval_importer_task.outputs['gcp_resources']`
    error_analysis_output_uri (Optional[str]):
      Path of error analysis annotations computed from image embeddings by finding nearest neighbors
      in the training set for each item in the test set.
inputs:
  - {name: model, type: google.VertexModel}
  - {name: evaluated_annotation_output_uri, type: String }
  - {name: evaluation_importer_gcp_resources, type: String }
  - {name: error_analysis_output_uri, type: String, optional: True}
outputs:
  - {name: gcp_resources, type: String}
implementation:
  container:
    image: gcr.io/ml-pipeline/google-cloud-pipeline-components:2.0.0b1
    command: [python3, -u, -m, google_cloud_pipeline_components.container.experimental.evaluation.import_evaluated_annotation]
    args:
      - --evaluated_annotation_output_uri
      - {inputValue: evaluated_annotation_output_uri}
      - --evaluation_importer_gcp_resources
      - {inputValue: evaluation_importer_gcp_resources}
      - if:
          cond: {isPresent: error_analysis_output_uri}
          then:
          - --error_analysis_output_uri
          - {inputValue: error_analysis_output_uri}
      - --pipeline_job_id
      - "{{$.pipeline_job_uuid}}"
      - --pipeline_job_resource_name
      - "{{$.pipeline_job_resource_name}}"
      - --model_name
      - "{{$.inputs.artifacts['model'].metadata['resourceName']}}"
      - --gcp_resources
      - {outputPath: gcp_resources}
