{
    "apiVersion": "argoproj.io/v1alpha1",
    "kind": "Workflow",
    "metadata": {
        "generateName": "xgboosttrainer-"
    },
    "spec": {
        "arguments": {
            "parameters": [
                {
                    "name": "output"
                },
                {
                    "name": "project"
                },
                {
                    "name": "region",
                    "value": "us-central1"
                },
                {
                    "name": "train-data",
                    "value": "gs://ml-pipeline-playground/sfpd/train.csv"
                },
                {
                    "name": "eval-data",
                    "value": "gs://ml-pipeline-playground/sfpd/eval.csv"
                },
                {
                    "name": "schema",
                    "value": "gs://ml-pipeline-playground/sfpd/schema.json"
                },
                {
                    "name": "target",
                    "value": "resolution"
                },
                {
                    "name": "rounds",
                    "value": "200"
                },
                {
                    "name": "workers",
                    "value": "2"
                },
                {
                    "name": "true-label",
                    "value": "ACTION"
                }
            ]
        },
        "entrypoint": "xgboosttrainer",
        "onExit": "delete-cluster",
        "templates": [
            {
                "container": {
                    "args": [
                        "--project",
                        "{{inputs.parameters.project}}",
                        "--region",
                        "{{inputs.parameters.region}}",
                        "--cluster",
                        "{{inputs.parameters.create-cluster-output}}",
                        "--schema",
                        "{{inputs.parameters.schema}}",
                        "--train",
                        "{{inputs.parameters.train-data}}",
                        "--output",
                        "{{inputs.parameters.output}}/{{workflow.name}}/analysis"
                    ],
                    "image": "gcr.io/ml-pipeline/ml-pipeline-dataproc-analyze:0.0.42"
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "create-cluster-output"
                        },
                        {
                            "name": "output"
                        },
                        {
                            "name": "project"
                        },
                        {
                            "name": "region"
                        },
                        {
                            "name": "schema"
                        },
                        {
                            "name": "train-data"
                        }
                    ]
                },
                "name": "analyze",
                "outputs": {
                    "artifacts": [
                        {
                            "name": "mlpipeline-ui-metadata",
                            "path": "/mlpipeline-ui-metadata.json",
                            "s3": {
                                "accessKeySecret": {
                                    "key": "accesskey",
                                    "name": "mlpipeline-minio-artifact"
                                },
                                "bucket": "mlpipeline",
                                "endpoint": "minio-service.kubeflow:9000",
                                "insecure": true,
                                "key": "runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz",
                                "secretKeySecret": {
                                    "key": "secretkey",
                                    "name": "mlpipeline-minio-artifact"
                                }
                            }
                        }
                    ],
                    "parameters": [
                        {
                            "name": "analyze-output",
                            "valueFrom": {
                                "path": "/output.txt"
                            }
                        }
                    ]
                }
            },
            {
                "container": {
                    "args": [
                        "--output",
                        "{{inputs.parameters.output}}/{{workflow.name}}/confusionmatrix",
                        "--predictions",
                        "{{inputs.parameters.predict-output}}"
                    ],
                    "image": "gcr.io/ml-pipeline/ml-pipeline-local-confusion-matrix:0.0.42"
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "output"
                        },
                        {
                            "name": "predict-output"
                        }
                    ]
                },
                "name": "confusion-matrix",
                "outputs": {
                    "artifacts": [
                        {
                            "name": "mlpipeline-ui-metadata",
                            "path": "/mlpipeline-ui-metadata.json",
                            "s3": {
                                "accessKeySecret": {
                                    "key": "accesskey",
                                    "name": "mlpipeline-minio-artifact"
                                },
                                "bucket": "mlpipeline",
                                "endpoint": "minio-service.kubeflow:9000",
                                "insecure": true,
                                "key": "runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz",
                                "secretKeySecret": {
                                    "key": "secretkey",
                                    "name": "mlpipeline-minio-artifact"
                                }
                            }
                        }
                    ]
                }
            },
            {
                "container": {
                    "args": [
                        "--project",
                        "{{inputs.parameters.project}}",
                        "--region",
                        "{{inputs.parameters.region}}",
                        "--name",
                        "xgb-{{workflow.name}}",
                        "--staging",
                        "{{inputs.parameters.output}}"
                    ],
                    "image": "gcr.io/ml-pipeline/ml-pipeline-dataproc-create-cluster:0.0.42"
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "output"
                        },
                        {
                            "name": "project"
                        },
                        {
                            "name": "region"
                        }
                    ]
                },
                "name": "create-cluster",
                "outputs": {
                    "artifacts": [
                        {
                            "name": "mlpipeline-ui-metadata",
                            "path": "/mlpipeline-ui-metadata.json",
                            "s3": {
                                "accessKeySecret": {
                                    "key": "accesskey",
                                    "name": "mlpipeline-minio-artifact"
                                },
                                "bucket": "mlpipeline",
                                "endpoint": "minio-service.kubeflow:9000",
                                "insecure": true,
                                "key": "runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz",
                                "secretKeySecret": {
                                    "key": "secretkey",
                                    "name": "mlpipeline-minio-artifact"
                                }
                            }
                        }
                    ],
                    "parameters": [
                        {
                            "name": "create-cluster-output",
                            "valueFrom": {
                                "path": "/output.txt"
                            }
                        }
                    ]
                }
            },
            {
                "container": {
                    "args": [
                        "--project",
                        "{{inputs.parameters.project}}",
                        "--region",
                        "{{inputs.parameters.region}}",
                        "--name",
                        "xgb-{{workflow.name}}"
                    ],
                    "image": "gcr.io/ml-pipeline/ml-pipeline-dataproc-delete-cluster:0.0.42"
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "project"
                        },
                        {
                            "name": "region"
                        }
                    ]
                },
                "name": "delete-cluster",
                "outputs": {
                    "artifacts": [
                        {
                            "name": "mlpipeline-ui-metadata",
                            "path": "/mlpipeline-ui-metadata.json",
                            "s3": {
                                "accessKeySecret": {
                                    "key": "accesskey",
                                    "name": "mlpipeline-minio-artifact"
                                },
                                "bucket": "mlpipeline",
                                "endpoint": "minio-service.kubeflow:9000",
                                "insecure": true,
                                "key": "runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz",
                                "secretKeySecret": {
                                    "key": "secretkey",
                                    "name": "mlpipeline-minio-artifact"
                                }
                            }
                        }
                    ]
                }
            },
            {
                "dag": {
                    "tasks": [
                        {
                            "arguments": {
                                "parameters": [
                                    {
                                        "name": "create-cluster-output",
                                        "value": "{{tasks.create-cluster.outputs.parameters.create-cluster-output}}"
                                    },
                                    {
                                        "name": "output",
                                        "value": "{{inputs.parameters.output}}"
                                    },
                                    {
                                        "name": "project",
                                        "value": "{{inputs.parameters.project}}"
                                    },
                                    {
                                        "name": "region",
                                        "value": "{{inputs.parameters.region}}"
                                    },
                                    {
                                        "name": "schema",
                                        "value": "{{inputs.parameters.schema}}"
                                    },
                                    {
                                        "name": "train-data",
                                        "value": "{{inputs.parameters.train-data}}"
                                    }
                                ]
                            },
                            "dependencies": [
                                "create-cluster"
                            ],
                            "name": "analyze",
                            "template": "analyze"
                        },
                        {
                            "arguments": {
                                "parameters": [
                                    {
                                        "name": "output",
                                        "value": "{{inputs.parameters.output}}"
                                    },
                                    {
                                        "name": "predict-output",
                                        "value": "{{tasks.predict.outputs.parameters.predict-output}}"
                                    }
                                ]
                            },
                            "dependencies": [
                                "predict"
                            ],
                            "name": "confusion-matrix",
                            "template": "confusion-matrix"
                        },
                        {
                            "arguments": {
                                "parameters": [
                                    {
                                        "name": "output",
                                        "value": "{{inputs.parameters.output}}"
                                    },
                                    {
                                        "name": "project",
                                        "value": "{{inputs.parameters.project}}"
                                    },
                                    {
                                        "name": "region",
                                        "value": "{{inputs.parameters.region}}"
                                    }
                                ]
                            },
                            "name": "create-cluster",
                            "template": "create-cluster"
                        },
                        {
                            "arguments": {
                                "parameters": [
                                    {
                                        "name": "analyze-output",
                                        "value": "{{tasks.analyze.outputs.parameters.analyze-output}}"
                                    },
                                    {
                                        "name": "create-cluster-output",
                                        "value": "{{tasks.create-cluster.outputs.parameters.create-cluster-output}}"
                                    },
                                    {
                                        "name": "output",
                                        "value": "{{inputs.parameters.output}}"
                                    },
                                    {
                                        "name": "project",
                                        "value": "{{inputs.parameters.project}}"
                                    },
                                    {
                                        "name": "region",
                                        "value": "{{inputs.parameters.region}}"
                                    },
                                    {
                                        "name": "target",
                                        "value": "{{inputs.parameters.target}}"
                                    },
                                    {
                                        "name": "train-output",
                                        "value": "{{tasks.train.outputs.parameters.train-output}}"
                                    },
                                    {
                                        "name": "transform-eval",
                                        "value": "{{tasks.transform.outputs.parameters.transform-eval}}"
                                    }
                                ]
                            },
                            "dependencies": [
                                "analyze",
                                "create-cluster",
                                "train",
                                "transform"
                            ],
                            "name": "predict",
                            "template": "predict"
                        },
                        {
                            "arguments": {
                                "parameters": [
                                    {
                                        "name": "output",
                                        "value": "{{inputs.parameters.output}}"
                                    },
                                    {
                                        "name": "predict-output",
                                        "value": "{{tasks.predict.outputs.parameters.predict-output}}"
                                    },
                                    {
                                        "name": "true-label",
                                        "value": "{{inputs.parameters.true-label}}"
                                    }
                                ]
                            },
                            "dependencies": [
                                "predict"
                            ],
                            "name": "roc",
                            "template": "roc"
                        },
                        {
                            "arguments": {
                                "parameters": [
                                    {
                                        "name": "analyze-output",
                                        "value": "{{tasks.analyze.outputs.parameters.analyze-output}}"
                                    },
                                    {
                                        "name": "create-cluster-output",
                                        "value": "{{tasks.create-cluster.outputs.parameters.create-cluster-output}}"
                                    },
                                    {
                                        "name": "output",
                                        "value": "{{inputs.parameters.output}}"
                                    },
                                    {
                                        "name": "project",
                                        "value": "{{inputs.parameters.project}}"
                                    },
                                    {
                                        "name": "region",
                                        "value": "{{inputs.parameters.region}}"
                                    },
                                    {
                                        "name": "rounds",
                                        "value": "{{inputs.parameters.rounds}}"
                                    },
                                    {
                                        "name": "target",
                                        "value": "{{inputs.parameters.target}}"
                                    },
                                    {
                                        "name": "transform-eval",
                                        "value": "{{tasks.transform.outputs.parameters.transform-eval}}"
                                    },
                                    {
                                        "name": "transform-train",
                                        "value": "{{tasks.transform.outputs.parameters.transform-train}}"
                                    },
                                    {
                                        "name": "workers",
                                        "value": "{{inputs.parameters.workers}}"
                                    }
                                ]
                            },
                            "dependencies": [
                                "analyze",
                                "create-cluster",
                                "transform"
                            ],
                            "name": "train",
                            "template": "train"
                        },
                        {
                            "arguments": {
                                "parameters": [
                                    {
                                        "name": "analyze-output",
                                        "value": "{{tasks.analyze.outputs.parameters.analyze-output}}"
                                    },
                                    {
                                        "name": "create-cluster-output",
                                        "value": "{{tasks.create-cluster.outputs.parameters.create-cluster-output}}"
                                    },
                                    {
                                        "name": "eval-data",
                                        "value": "{{inputs.parameters.eval-data}}"
                                    },
                                    {
                                        "name": "output",
                                        "value": "{{inputs.parameters.output}}"
                                    },
                                    {
                                        "name": "project",
                                        "value": "{{inputs.parameters.project}}"
                                    },
                                    {
                                        "name": "region",
                                        "value": "{{inputs.parameters.region}}"
                                    },
                                    {
                                        "name": "target",
                                        "value": "{{inputs.parameters.target}}"
                                    },
                                    {
                                        "name": "train-data",
                                        "value": "{{inputs.parameters.train-data}}"
                                    }
                                ]
                            },
                            "dependencies": [
                                "analyze",
                                "create-cluster"
                            ],
                            "name": "transform",
                            "template": "transform"
                        }
                    ]
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "eval-data"
                        },
                        {
                            "name": "output"
                        },
                        {
                            "name": "project"
                        },
                        {
                            "name": "region"
                        },
                        {
                            "name": "rounds"
                        },
                        {
                            "name": "schema"
                        },
                        {
                            "name": "target"
                        },
                        {
                            "name": "train-data"
                        },
                        {
                            "name": "true-label"
                        },
                        {
                            "name": "workers"
                        }
                    ]
                },
                "name": "exit-handler-1"
            },
            {
                "container": {
                    "args": [
                        "--project",
                        "{{inputs.parameters.project}}",
                        "--region",
                        "{{inputs.parameters.region}}",
                        "--cluster",
                        "{{inputs.parameters.create-cluster-output}}",
                        "--predict",
                        "{{inputs.parameters.transform-eval}}",
                        "--analysis",
                        "{{inputs.parameters.analyze-output}}",
                        "--target",
                        "{{inputs.parameters.target}}",
                        "--package",
                        "gs://ml-pipeline-playground/xgboost4j-example-0.8-SNAPSHOT-jar-with-dependencies.jar",
                        "--model",
                        "{{inputs.parameters.train-output}}",
                        "--output",
                        "{{inputs.parameters.output}}/{{workflow.name}}/predict"
                    ],
                    "image": "gcr.io/ml-pipeline/ml-pipeline-dataproc-predict:0.0.42"
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "analyze-output"
                        },
                        {
                            "name": "create-cluster-output"
                        },
                        {
                            "name": "output"
                        },
                        {
                            "name": "project"
                        },
                        {
                            "name": "region"
                        },
                        {
                            "name": "target"
                        },
                        {
                            "name": "train-output"
                        },
                        {
                            "name": "transform-eval"
                        }
                    ]
                },
                "name": "predict",
                "outputs": {
                    "artifacts": [
                        {
                            "name": "mlpipeline-ui-metadata",
                            "path": "/mlpipeline-ui-metadata.json",
                            "s3": {
                                "accessKeySecret": {
                                    "key": "accesskey",
                                    "name": "mlpipeline-minio-artifact"
                                },
                                "bucket": "mlpipeline",
                                "endpoint": "minio-service.kubeflow:9000",
                                "insecure": true,
                                "key": "runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz",
                                "secretKeySecret": {
                                    "key": "secretkey",
                                    "name": "mlpipeline-minio-artifact"
                                }
                            }
                        }
                    ],
                    "parameters": [
                        {
                            "name": "predict-output",
                            "valueFrom": {
                                "path": "/output.txt"
                            }
                        }
                    ]
                }
            },
            {
                "container": {
                    "args": [
                        "--output",
                        "{{inputs.parameters.output}}/{{workflow.name}}/roc",
                        "--predictions",
                        "{{inputs.parameters.predict-output}}",
                        "--trueclass",
                        "{{inputs.parameters.true-label}}"
                    ],
                    "image": "gcr.io/ml-pipeline/ml-pipeline-local-roc:0.0.42"
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "output"
                        },
                        {
                            "name": "predict-output"
                        },
                        {
                            "name": "true-label"
                        }
                    ]
                },
                "name": "roc",
                "outputs": {
                    "artifacts": [
                        {
                            "name": "mlpipeline-ui-metadata",
                            "path": "/mlpipeline-ui-metadata.json",
                            "s3": {
                                "accessKeySecret": {
                                    "key": "accesskey",
                                    "name": "mlpipeline-minio-artifact"
                                },
                                "bucket": "mlpipeline",
                                "endpoint": "minio-service.kubeflow:9000",
                                "insecure": true,
                                "key": "runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz",
                                "secretKeySecret": {
                                    "key": "secretkey",
                                    "name": "mlpipeline-minio-artifact"
                                }
                            }
                        }
                    ]
                }
            },
            {
                "container": {
                    "args": [
                        "--project",
                        "{{inputs.parameters.project}}",
                        "--region",
                        "{{inputs.parameters.region}}",
                        "--cluster",
                        "{{inputs.parameters.create-cluster-output}}",
                        "--train",
                        "{{inputs.parameters.transform-train}}",
                        "--eval",
                        "{{inputs.parameters.transform-eval}}",
                        "--analysis",
                        "{{inputs.parameters.analyze-output}}",
                        "--target",
                        "{{inputs.parameters.target}}",
                        "--package",
                        "gs://ml-pipeline-playground/xgboost4j-example-0.8-SNAPSHOT-jar-with-dependencies.jar",
                        "--workers",
                        "{{inputs.parameters.workers}}",
                        "--rounds",
                        "{{inputs.parameters.rounds}}",
                        "--conf",
                        "gs://ml-pipeline-playground/trainconfcla.json",
                        "--output",
                        "{{inputs.parameters.output}}/{{workflow.name}}/model"
                    ],
                    "image": "gcr.io/ml-pipeline/ml-pipeline-dataproc-train:0.0.42"
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "analyze-output"
                        },
                        {
                            "name": "create-cluster-output"
                        },
                        {
                            "name": "output"
                        },
                        {
                            "name": "project"
                        },
                        {
                            "name": "region"
                        },
                        {
                            "name": "rounds"
                        },
                        {
                            "name": "target"
                        },
                        {
                            "name": "transform-eval"
                        },
                        {
                            "name": "transform-train"
                        },
                        {
                            "name": "workers"
                        }
                    ]
                },
                "name": "train",
                "outputs": {
                    "artifacts": [
                        {
                            "name": "mlpipeline-ui-metadata",
                            "path": "/mlpipeline-ui-metadata.json",
                            "s3": {
                                "accessKeySecret": {
                                    "key": "accesskey",
                                    "name": "mlpipeline-minio-artifact"
                                },
                                "bucket": "mlpipeline",
                                "endpoint": "minio-service.kubeflow:9000",
                                "insecure": true,
                                "key": "runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz",
                                "secretKeySecret": {
                                    "key": "secretkey",
                                    "name": "mlpipeline-minio-artifact"
                                }
                            }
                        }
                    ],
                    "parameters": [
                        {
                            "name": "train-output",
                            "valueFrom": {
                                "path": "/output.txt"
                            }
                        }
                    ]
                }
            },
            {
                "container": {
                    "args": [
                        "--project",
                        "{{inputs.parameters.project}}",
                        "--region",
                        "{{inputs.parameters.region}}",
                        "--cluster",
                        "{{inputs.parameters.create-cluster-output}}",
                        "--train",
                        "{{inputs.parameters.train-data}}",
                        "--eval",
                        "{{inputs.parameters.eval-data}}",
                        "--analysis",
                        "{{inputs.parameters.analyze-output}}",
                        "--target",
                        "{{inputs.parameters.target}}",
                        "--output",
                        "{{inputs.parameters.output}}/{{workflow.name}}/transform"
                    ],
                    "image": "gcr.io/ml-pipeline/ml-pipeline-dataproc-transform:0.0.42"
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "analyze-output"
                        },
                        {
                            "name": "create-cluster-output"
                        },
                        {
                            "name": "eval-data"
                        },
                        {
                            "name": "output"
                        },
                        {
                            "name": "project"
                        },
                        {
                            "name": "region"
                        },
                        {
                            "name": "target"
                        },
                        {
                            "name": "train-data"
                        }
                    ]
                },
                "name": "transform",
                "outputs": {
                    "artifacts": [
                        {
                            "name": "mlpipeline-ui-metadata",
                            "path": "/mlpipeline-ui-metadata.json",
                            "s3": {
                                "accessKeySecret": {
                                    "key": "accesskey",
                                    "name": "mlpipeline-minio-artifact"
                                },
                                "bucket": "mlpipeline",
                                "endpoint": "minio-service.kubeflow:9000",
                                "insecure": true,
                                "key": "runs/{{workflow.uid}}/{{pod.name}}/mlpipeline-ui-metadata.tgz",
                                "secretKeySecret": {
                                    "key": "secretkey",
                                    "name": "mlpipeline-minio-artifact"
                                }
                            }
                        }
                    ],
                    "parameters": [
                        {
                            "name": "transform-eval",
                            "valueFrom": {
                                "path": "/output_eval.txt"
                            }
                        },
                        {
                            "name": "transform-train",
                            "valueFrom": {
                                "path": "/output_train.txt"
                            }
                        }
                    ]
                }
            },
            {
                "dag": {
                    "tasks": [
                        {
                            "arguments": {
                                "parameters": [
                                    {
                                        "name": "eval-data",
                                        "value": "{{inputs.parameters.eval-data}}"
                                    },
                                    {
                                        "name": "output",
                                        "value": "{{inputs.parameters.output}}"
                                    },
                                    {
                                        "name": "project",
                                        "value": "{{inputs.parameters.project}}"
                                    },
                                    {
                                        "name": "region",
                                        "value": "{{inputs.parameters.region}}"
                                    },
                                    {
                                        "name": "rounds",
                                        "value": "{{inputs.parameters.rounds}}"
                                    },
                                    {
                                        "name": "schema",
                                        "value": "{{inputs.parameters.schema}}"
                                    },
                                    {
                                        "name": "target",
                                        "value": "{{inputs.parameters.target}}"
                                    },
                                    {
                                        "name": "train-data",
                                        "value": "{{inputs.parameters.train-data}}"
                                    },
                                    {
                                        "name": "true-label",
                                        "value": "{{inputs.parameters.true-label}}"
                                    },
                                    {
                                        "name": "workers",
                                        "value": "{{inputs.parameters.workers}}"
                                    }
                                ]
                            },
                            "name": "exit-handler-1",
                            "template": "exit-handler-1"
                        }
                    ]
                },
                "inputs": {
                    "parameters": [
                        {
                            "name": "eval-data"
                        },
                        {
                            "name": "output"
                        },
                        {
                            "name": "project"
                        },
                        {
                            "name": "region"
                        },
                        {
                            "name": "rounds"
                        },
                        {
                            "name": "schema"
                        },
                        {
                            "name": "target"
                        },
                        {
                            "name": "train-data"
                        },
                        {
                            "name": "true-label"
                        },
                        {
                            "name": "workers"
                        }
                    ]
                },
                "name": "xgboosttrainer"
            }
        ]
    }
}
