apiVersion: sonataflow.org/v1alpha08
kind: SonataFlow
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: >
      {"apiVersion":"sonataflow.org/v1alpha08","kind":"SonataFlow","metadata":{"annotations":{"sonataflow.org/description":"Inference
      Pipeline with
      SonataFlow","sonataflow.org/profile":"dev","sonataflow.org/version":"1.0"},"name":"pipeline","namespace":"sonataflow-inference-pipeline-demo"},"spec":{"flow":{"functions":[{"name":"python","operation":"script:python","type":"custom"},{"name":"invoke_kserve","operation":"classpath:specs/model_openapi.yaml#infer"}],"start":"Imports","states":[{"actions":[{"functionRef":{"arguments":{"script":"import
      sys\nsys.path.append('./src/main/resources/python')\nfrom coco_to_kserve
      import to_kserve\nfrom response_handler import
      handle_response\n"},"refName":"python"}}],"name":"Imports","transition":"Inference
      pre-processing","type":"operation"},{"actions":[{"functionRef":{"arguments":{"base64Image":".base64Image","script":"kserve_payload
      = to_kserve(base64Image)"},"refName":"python"}}],"name":"Inference
      pre-processing","stateDataFilter":{"output":"{kserve_payload:$WORKFLOW.python.kserve_payload,
      base64Image: .base64Image}"},"transition":"Invoke
      KServe","type":"operation"},{"actions":[{"functionRef":{"arguments":{"inputs":".kserve_payload.inputs"},"refName":"invoke_kserve"}}],"name":"Invoke
      KServe","stateDataFilter":{"output":"{kserve_response: .outputs,
      base64Image: .base64Image}"},"transition":"Inference
      post-processing","type":"operation"},{"actions":[{"functionRef":{"arguments":{"image":".base64Image","kserve_response":".kserve_response","script":"output_image
      = handle_response(base64Image,
      kserve_response)"},"refName":"python"}}],"end":true,"name":"Inference
      post-processing","stateDataFilter":{"output":"{output_image:
      $WORKFLOW.python.output_image}"},"type":"operation"}]},"resources":{"configMaps":[{"configMap":{"name":"pipeline-specs"},"workflowPath":"specs"},{"configMap":{"name":"pipeline-python"},"workflowPath":"python"},{"configMap":{"name":"pipeline-frontend"},"workflowPath":"META-INF/resources"}]}}}
    sonataflow.org/description: Inference Pipeline with SonataFlow
    sonataflow.org/profile: dev
    sonataflow.org/version: '1.0'
  creationTimestamp: '2023-10-17T20:41:25Z'
  generation: 1
  name: pipeline
  namespace: sonataflow-inference-pipeline-demo
  resourceVersion: '28415516'
  uid: f320b453-dfb9-4b09-8d73-7be592472641
spec:
  flow:
    functions:
      - name: python
        operation: 'script:python'
        type: custom
      - name: invoke_kserve
        operation: 'classpath:specs/model_openapi.yaml#infer'
        type: rest
    start: Imports
    states:
      - actions:
          - functionRef:
              arguments:
                script: |
                  import sys
                  sys.path.append('./src/main/resources/python')
                  from coco_to_kserve import to_kserve
                  from response_handler import handle_response
              refName: python
        name: Imports
        transition: Inference pre-processing
        type: operation
      - actions:
          - functionRef:
              arguments:
                base64Image: .base64Image
                script: kserve_payload = to_kserve(base64Image)
              refName: python
        name: Inference pre-processing
        stateDataFilter:
          output: >-
            {kserve_payload:$WORKFLOW.python.kserve_payload, base64Image:
            .base64Image}
        transition: Invoke KServe
        type: operation
      - actions:
          - functionRef:
              arguments:
                inputs: .kserve_payload.inputs
              refName: invoke_kserve
        name: Invoke KServe
        stateDataFilter:
          output: '{kserve_response: .outputs, base64Image: .base64Image}'
        transition: Inference post-processing
        type: operation
      - actions:
          - functionRef:
              arguments:
                image: .base64Image
                kserve_response: .kserve_response
                script: 'output_image = handle_response(base64Image, kserve_response)'
              refName: python
        end: true
        name: Inference post-processing
        stateDataFilter:
          output: '{output_image: $WORKFLOW.python.output_image}'
        type: operation
  resources:
    configMaps:
      - configMap:
          name: pipeline-specs
        workflowPath: specs
      - configMap:
          name: pipeline-python
        workflowPath: python
      - configMap:
          name: pipeline-frontend
        workflowPath: META-INF/resources
status:
  address:
    url: >-
      https://pipeline-sonataflow-inference-pipeline-demo.apps.hbelmiro.dev.datahub.redhat.com/pipeline
  conditions:
    - lastUpdateTime: '2023-10-17T20:41:30Z'
      status: Unknown
      type: Built
    - lastUpdateTime: '2023-10-17T20:45:08Z'
      message: 'Can''t recover workflow from failure after maximum attempts: 3'
      reason: AttemptToRedeployFailed
      status: 'False'
      type: Running
  endpoint: >-
    https://pipeline-sonataflow-inference-pipeline-demo.apps.hbelmiro.dev.datahub.redhat.com/pipeline
  lastTimeRecoverAttempt: '2023-10-17T20:45:08Z'
  observedGeneration: 1
  recoverFailureAttempts: 3
