Exemple #1
0
def flipcoin():
    flip = FlipCoinOp('flip')

    with dsl.Condition(flip.output == 'heads'):
        flip2 = FlipCoinOp('flip-again')

        with dsl.Condition(flip2.output == 'tails'):
            PrintOp('print1', flip2.output)

    with dsl.Condition(flip.output == 'tails'):
        PrintOp('print2', flip2.output)
def my_pipeline():
    flip1 = flip_coin_op()
    print_op(flip1.output)
    flip2 = flip_coin_op()
    print_op(flip2.output)

    with dsl.Condition(flip1.output != 'no-such-result'):  # always true
        flip3 = flip_coin_op()
        print_op(flip3.output)

        with dsl.Condition(flip2.output == flip3.output):
            flip4 = flip_coin_op()
            print_op(flip4.output)
Exemple #3
0
def condition(text: str = 'condition test', force_flip_result: str = ''):
    flip1 = flip_coin_op(force_flip_result)
    print_op(flip1.output)

    with dsl.Condition(flip1.output == 'heads'):
        flip2 = flip_coin_op()
        print_op(flip2.output)
        print_op(text)
Exemple #4
0
def flip_component(flip_result):
    print_flip = print_op(flip_result)
    flipA = flip_coin_op().after(print_flip)
    # set max_cache_staleness to 0 to prevent infinite loop due to caching
    flipA.execution_options.caching_strategy.max_cache_staleness = "P0D"
    with dsl.Condition(flipA.output == 'heads'):
        # When the flip_component is called recursively, the flipA.output
        # from inside the graph component will be passed to the next flip_component
        # as the input whereas the flip_result in the current graph component
        # comes from the flipA.output in the flipcoin function.
        flip_component(flipA.output)
Exemple #5
0
def uri_artifact(text: str = 'Hello world!'):
    task_1 = write_to_gcs(text=text)
    task_2 = read_from_gcs(input_gcs_path=task_1.outputs['output_gcs_path'])

    # Test use URI within ParFor loop.
    loop_args = [1, 2, 3, 4]
    with dsl.ParallelFor(loop_args) as loop_arg:
        loop_task_2 = read_from_gcs(
            input_gcs_path=task_1.outputs['output_gcs_path'])

    # Test use URI within condition.
    flip = flip_coin_op()
    with dsl.Condition(flip.output == 'heads'):
        condition_task_2 = read_from_gcs(
            input_gcs_path=task_1.outputs['output_gcs_path'])
def flip_component(flip_result):
    print_flip = PrintOp(flip_result)
    flipA = FlipCoinOp().after(print_flip)
    with dsl.Condition(flipA.output == 'heads'):
        flip_component(flipA.output)
 def flip_component(flip_result):
     with dsl.Condition(flip_result == 'heads'):
         flip_component(flip_result)