|
| 1 | +# Copyright 2021 kubeflow.org |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +apiVersion: tekton.dev/v1beta1 |
| 16 | +kind: PipelineRun |
| 17 | +metadata: |
| 18 | + name: pipeline |
| 19 | + annotations: |
| 20 | + tekton.dev/output_artifacts: '{"false": [{"key": "artifacts/$PIPELINERUN/false/Output.tgz", |
| 21 | + "name": "false-Output", "path": "/tmp/outputs/Output/data"}]}' |
| 22 | + tekton.dev/input_artifacts: '{}' |
| 23 | + tekton.dev/artifact_bucket: mlpipeline |
| 24 | + tekton.dev/artifact_endpoint: minio-service.kubeflow:9000 |
| 25 | + tekton.dev/artifact_endpoint_scheme: http:// |
| 26 | + tekton.dev/artifact_items: '{"false": [["Output", "$(results.output.path)"]], |
| 27 | + "my-in-coop1": [], "my-in-coop1-2": [], "my-in-coop1-3": []}' |
| 28 | + sidecar.istio.io/inject: "false" |
| 29 | + pipelines.kubeflow.org/big_data_passing_format: $(workspaces.$TASK_NAME.path)/artifacts/$ORIG_PR_NAME/$TASKRUN_NAME/$TASK_PARAM_NAME |
| 30 | + pipelines.kubeflow.org/pipeline_spec: '{"inputs": [{"default": "10", "name": "param", |
| 31 | + "optional": true, "type": "Integer"}], "name": "pipeline"}' |
| 32 | +spec: |
| 33 | + params: |
| 34 | + - name: param |
| 35 | + value: '10' |
| 36 | + pipelineSpec: |
| 37 | + params: |
| 38 | + - name: param |
| 39 | + default: '10' |
| 40 | + tasks: |
| 41 | + - name: "false" |
| 42 | + taskSpec: |
| 43 | + steps: |
| 44 | + - name: main |
| 45 | + args: |
| 46 | + - '----output-paths' |
| 47 | + - $(results.output.path) |
| 48 | + command: |
| 49 | + - sh |
| 50 | + - -ec |
| 51 | + - | |
| 52 | + program_path=$(mktemp) |
| 53 | + printf "%s" "$0" > "$program_path" |
| 54 | + python3 -u "$program_path" "$@" |
| 55 | + - | |
| 56 | + def false(): |
| 57 | + return 'false' |
| 58 | +
|
| 59 | + def _serialize_str(str_value: str) -> str: |
| 60 | + if not isinstance(str_value, str): |
| 61 | + raise TypeError('Value "{}" has type "{}" instead of str.'.format( |
| 62 | + str(str_value), str(type(str_value)))) |
| 63 | + return str_value |
| 64 | +
|
| 65 | + import argparse |
| 66 | + _parser = argparse.ArgumentParser(prog='False', description='') |
| 67 | + _parser.add_argument("----output-paths", dest="_output_paths", type=str, nargs=1) |
| 68 | + _parsed_args = vars(_parser.parse_args()) |
| 69 | + _output_files = _parsed_args.pop("_output_paths", []) |
| 70 | +
|
| 71 | + _outputs = false(**_parsed_args) |
| 72 | +
|
| 73 | + _outputs = [_outputs] |
| 74 | +
|
| 75 | + _output_serializers = [ |
| 76 | + _serialize_str, |
| 77 | +
|
| 78 | + ] |
| 79 | +
|
| 80 | + import os |
| 81 | + for idx, output_file in enumerate(_output_files): |
| 82 | + try: |
| 83 | + os.makedirs(os.path.dirname(output_file)) |
| 84 | + except OSError: |
| 85 | + pass |
| 86 | + with open(output_file, 'w') as f: |
| 87 | + f.write(_output_serializers[idx](_outputs[idx])) |
| 88 | + image: python:alpine3.6 |
| 89 | + results: |
| 90 | + - name: output |
| 91 | + type: string |
| 92 | + description: /tmp/outputs/Output/data |
| 93 | + metadata: |
| 94 | + labels: |
| 95 | + pipelines.kubeflow.org/pipelinename: '' |
| 96 | + pipelines.kubeflow.org/generation: '' |
| 97 | + pipelines.kubeflow.org/cache_enabled: "true" |
| 98 | + annotations: |
| 99 | + pipelines.kubeflow.org/component_spec_digest: '{"name": "False", "outputs": |
| 100 | + [{"name": "Output", "type": "String"}], "version": "False@sha256=ab6d70d69626be9a388e3d6d92c4eae87095dc005400a41e6613f4b855c694f6"}' |
| 101 | + tekton.dev/template: '' |
| 102 | + timeout: 525600m |
| 103 | + - name: my-in-coop1 |
| 104 | + params: |
| 105 | + - name: param |
| 106 | + value: $(params.param) |
| 107 | + taskSpec: |
| 108 | + steps: |
| 109 | + - name: main |
| 110 | + args: |
| 111 | + - | |
| 112 | + set -e |
| 113 | + echo op1 "$0" "$1" |
| 114 | + - '1' |
| 115 | + - $(inputs.params.param) |
| 116 | + command: |
| 117 | + - sh |
| 118 | + - -c |
| 119 | + image: library/bash:4.4.23 |
| 120 | + params: |
| 121 | + - name: param |
| 122 | + metadata: |
| 123 | + labels: |
| 124 | + pipelines.kubeflow.org/pipelinename: '' |
| 125 | + pipelines.kubeflow.org/generation: '' |
| 126 | + pipelines.kubeflow.org/cache_enabled: "true" |
| 127 | + annotations: |
| 128 | + pipelines.kubeflow.org/component_spec_digest: '{"name": "my-in-coop1", |
| 129 | + "outputs": [], "version": "my-in-coop1@sha256=8ccab3a28a39a406554d964865f2ccb0aed854a43b6de827f613eff2bccd6f8f"}' |
| 130 | + tekton.dev/template: '' |
| 131 | + when: |
| 132 | + - input: $(tasks.condition-1.results.outcome) |
| 133 | + operator: in |
| 134 | + values: |
| 135 | + - "true" |
| 136 | + timeout: 525600m |
| 137 | + - name: my-in-coop1-2 |
| 138 | + params: |
| 139 | + - name: param |
| 140 | + value: $(params.param) |
| 141 | + taskSpec: |
| 142 | + steps: |
| 143 | + - name: main |
| 144 | + args: |
| 145 | + - | |
| 146 | + set -e |
| 147 | + echo op1 "$0" "$1" |
| 148 | + - '1' |
| 149 | + - $(inputs.params.param) |
| 150 | + command: |
| 151 | + - sh |
| 152 | + - -c |
| 153 | + image: library/bash:4.4.23 |
| 154 | + params: |
| 155 | + - name: param |
| 156 | + metadata: |
| 157 | + labels: |
| 158 | + pipelines.kubeflow.org/pipelinename: '' |
| 159 | + pipelines.kubeflow.org/generation: '' |
| 160 | + pipelines.kubeflow.org/cache_enabled: "true" |
| 161 | + annotations: |
| 162 | + pipelines.kubeflow.org/component_spec_digest: '{"name": "my-in-coop1", |
| 163 | + "outputs": [], "version": "my-in-coop1@sha256=8ccab3a28a39a406554d964865f2ccb0aed854a43b6de827f613eff2bccd6f8f"}' |
| 164 | + tekton.dev/template: '' |
| 165 | + runAfter: |
| 166 | + - my-in-coop1-3 |
| 167 | + timeout: 525600m |
| 168 | + when: |
| 169 | + - input: $(tasks.condition-1.results.outcome) |
| 170 | + operator: in |
| 171 | + values: |
| 172 | + - "true" |
| 173 | + - name: my-in-coop1-3 |
| 174 | + params: |
| 175 | + - name: param |
| 176 | + value: $(params.param) |
| 177 | + taskSpec: |
| 178 | + steps: |
| 179 | + - name: main |
| 180 | + args: |
| 181 | + - | |
| 182 | + set -e |
| 183 | + echo op1 "$0" "$1" |
| 184 | + - '1' |
| 185 | + - $(inputs.params.param) |
| 186 | + command: |
| 187 | + - sh |
| 188 | + - -c |
| 189 | + image: library/bash:4.4.23 |
| 190 | + params: |
| 191 | + - name: param |
| 192 | + metadata: |
| 193 | + labels: |
| 194 | + pipelines.kubeflow.org/pipelinename: '' |
| 195 | + pipelines.kubeflow.org/generation: '' |
| 196 | + pipelines.kubeflow.org/cache_enabled: "true" |
| 197 | + annotations: |
| 198 | + pipelines.kubeflow.org/component_spec_digest: '{"name": "my-in-coop1", |
| 199 | + "outputs": [], "version": "my-in-coop1@sha256=8ccab3a28a39a406554d964865f2ccb0aed854a43b6de827f613eff2bccd6f8f"}' |
| 200 | + tekton.dev/template: '' |
| 201 | + runAfter: |
| 202 | + - my-in-coop1 |
| 203 | + timeout: 525600m |
| 204 | + when: |
| 205 | + - input: $(tasks.condition-1.results.outcome) |
| 206 | + operator: in |
| 207 | + values: |
| 208 | + - "true" |
| 209 | + - name: condition-1 |
| 210 | + params: |
| 211 | + - name: operand1 |
| 212 | + value: $(tasks.false.results.output) |
| 213 | + - name: operand2 |
| 214 | + value: "true" |
| 215 | + - name: operator |
| 216 | + value: == |
| 217 | + taskSpec: |
| 218 | + results: |
| 219 | + - name: outcome |
| 220 | + type: string |
| 221 | + description: Conditional task outcome |
| 222 | + params: |
| 223 | + - name: operand1 |
| 224 | + - name: operand2 |
| 225 | + - name: operator |
| 226 | + steps: |
| 227 | + - name: main |
| 228 | + command: |
| 229 | + - sh |
| 230 | + - -ec |
| 231 | + - program_path=$(mktemp); printf "%s" "$0" > "$program_path"; python3 -u |
| 232 | + "$program_path" "$1" "$2" |
| 233 | + args: |
| 234 | + - | |
| 235 | + import sys |
| 236 | + input1=str.rstrip(sys.argv[1]) |
| 237 | + input2=str.rstrip(sys.argv[2]) |
| 238 | + try: |
| 239 | + input1=int(input1) |
| 240 | + input2=int(input2) |
| 241 | + except: |
| 242 | + input1=str(input1) |
| 243 | + outcome="true" if (input1 $(inputs.params.operator) input2) else "false" |
| 244 | + f = open("/tekton/results/outcome", "w") |
| 245 | + f.write(outcome) |
| 246 | + f.close() |
| 247 | + - $(inputs.params.operand1) |
| 248 | + - $(inputs.params.operand2) |
| 249 | + image: python:alpine3.6 |
| 250 | + timeout: 525600m |
0 commit comments