import { PipelineSpec } from 'src/generated/pipeline_spec' ; import { ml_pipelines } from 'src/generated/pipeline_spec/pbjs_ml_pipelines' ; import { Workflow } from 'src/third_party/mlmd/argo_template' ; export function isV2Pipeline ( workflow ) { return workflow ?. metadata ?. annotations ?. [ 'pipelines.kubeflow.org/v2_pipeline' ] === 'true' ; } export function isArgoWorkflowTemplate ( template ) { if ( template ?. kind === 'Workflow' && template ?. apiVersion ?. startsWith ( 'argoproj.io/' ) ) { return true ; } return false ; } export function isTektonPipelineRunTemplate ( template ) { if ( template ?. kind === 'PipelineRun' && template ?. apiVersion ?. startsWith ( 'tekton.dev/' ) ) { return true ; } return false ; } export function convertJsonToV2PipelineSpec ( template ) { const pipelineJob = JSON . parse ( template ) ; const message = ml_pipelines . PipelineSpec . fromObject ( pipelineJob [ 'pipelineSpec' ] ) ; const buffer = ml_pipelines . PipelineSpec . encode ( message ) . finish ( ) ; const pipelineSpec = PipelineSpec . deserializeBinary ( buffer ) ; return pipelineSpec ; }