name: Consume data inputs: - {name: iter, type: Integer} - {name: data, type: Integer} implementation: container: image: busybox command: - echo - {inputValue: iter} - {inputValue: data} ''') @dsl.pipeline( name='loop-with-enumerate-basic', description='Test pipeline to verify functions of par loop.' ) def pipeline(): source_task = produce_op() with Loop(source_task.outputs['data_list']).enumerate() as (i, item): consume_op(iter=i, data=item) if __name__ == '__main__': from kfp_tekton.compiler import TektonCompiler compiler = TektonCompiler() compiler.compile(pipeline, __file__.replace('.py', '.yaml')) # compiler.tekton_inline_spec = False # compiler.compile(pipeline, __file__.replace('.py', '_noninlined.yaml'))
""" Args: name: An identifier of the step which needs to be unique within a pipeline. url: the gcs url to download the message from. """ super(DownloadMessageOp, self).__init__( name=name, image='google/cloud-sdk', command=['sh', '-c'], arguments=['gsutil cat %s | tee /tmp/results.txt' % url], file_outputs={'downloaded': '/tmp/results.txt'}) @dsl.pipeline(name='Download and Save Most Frequent', description='Download and Get Most Frequent Word and Save to GCS' ) def download_save_most_frequent_word( url: str = 'gs://ml-pipeline-playground/shakespeare1.txt', outputpath: str = '/tmp/output.txt'): downloader = DownloadMessageOp('download', url) save_most_frequent_word(downloader.output, outputpath) if __name__ == '__main__': from kfp_tekton.compiler import TektonCompiler tkc = TektonCompiler() tkc.compile(save_most_frequent_word, __file__.replace( '.py', '.yaml')) # Check if simple pipeline can be compiled tkc.compile(download_save_most_frequent_word, __file__.replace('.py', '.yaml'))
print_msg, base_image='python:alpine3.6') random_num_op = components.create_component_from_func( random_num, base_image='python:alpine3.6') @dsl.pipeline( name='conditional-execution-pipeline', description='Shows how to use dsl.Condition().' ) def flipcoin_pipeline(): flip = flip_coin_op() with dsl.Condition(flip.output == 'heads'): random_num_head = random_num_op(0, 9) with dsl.Condition(random_num_head.output > 5): print_op('heads and %s > 5!' % random_num_head.output) with dsl.Condition(random_num_head.output <= 5): print_op('heads and %s <= 5!' % random_num_head.output) with dsl.Condition(flip.output == 'tails'): random_num_tail = random_num_op(10, 19) with dsl.Condition(random_num_tail.output > 15): print_op('tails and %s > 15!' % random_num_tail.output) with dsl.Condition(random_num_tail.output <= 15): print_op('tails and %s <= 15!' % random_num_tail.output) if __name__ == '__main__': from kfp_tekton.compiler import TektonCompiler compiler = TektonCompiler() compiler.produce_taskspec = False compiler.compile(flipcoin_pipeline, __file__.replace('.py', '.yaml'))