def my_wf(a: int, b: str) -> (int, str):
     x, y = t1(a=a)
     d = (conditional("test1").if_(x == 4).then(t2(a=b)).elif_(x >= 5).then(
         t2(a=y)).else_().fail("Unable to choose branch"))
     f = conditional("test2").if_(d == "hello ").then(
         t2(a="It is hello")).else_().then(t2(a="Not Hello!"))
     return x, f
Пример #2
0
def multiplier_2(my_input: float) -> float:
    return (
        conditional("fractions").if_((my_input > 0.1) & (my_input < 1.0)).then(
            double(
                n=my_input)).elif_((my_input > 1.0) & (my_input < 10.0)).then(
                    square(n=my_input)).else_().fail(
                        "The input must be between 0 and 10"))
Пример #3
0
def multiplier_3(my_input: float) -> float:
    d = (conditional("fractions").if_((my_input > 0.1)
                                      & (my_input < 1.0)).then(
                                          double(n=my_input)).
         elif_((my_input > 1.0) & (my_input < 10.0)).then(square(
             n=my_input)).else_().fail("The input must be between 0 and 10"))

    # d will be either the output of `double` or t he output of `square`. If the conditional() falls through the fail
    # branch, execution will not reach here.
    return double(n=d)
Пример #4
0
    def math_ops(a: int, b: int) -> (int, int):
        # Flyte will only make `sum` and `sub` available as outputs because they are common between all branches
        sum, sub = (
            conditional("noDivByZero")
            .if_(a > b)
            .then(sum_sub(a=a, b=b))
            .else_()
            .fail("Only positive results are allowed")
        )

        return sum, sub
Пример #5
0
 def my_wf(a: int, b: str) -> (int, str):
     x, y = t1(a=a)
     d = (
         conditional("test1")
         .if_(x == 4)
         .then(t2(a=b))
         .elif_(x >= 5)
         .then(t2(a=y))
         .else_()
         .fail("All Branches failed")
     )
     return x, d
 def merge_sort(in1: typing.List[int], count: int) -> typing.List[int]:
     return (conditional("terminal_case").if_(count < 500).then(
         merge_sort_locally(in1=in1)).elif_(count < 1000).then(
             also_merge_sort_locally(in1=in1)).else_().then(
                 merge_sort_remotely(in1=in1)))
 def my_wf(a: int) -> str:
     c = mimic(a=a)
     return conditional("test1").if_(c.c == 4).then(
         t1(c=c.c).c).else_().then(t2().c)
 def my_wf(a: int) -> int:
     d = (conditional("test1").if_((a == 4) | (a == 3)).then(t1(a=a)).elif_(
         a < 6).then(t1(a=a)).else_().fail("Unable to choose branch"))
     return d
 def my_wf(a: int) -> int:
     d = conditional("test1").if_(a > 3).then(t1(a=a)).else_().then(
         my_sub_wf(a=a))
     return d
Пример #10
0
 def decompose() -> int:
     result = return_true()
     return conditional("test").if_(result.is_true()).then(success()).else_().then(failed())
Пример #11
0
 def decompose_none() -> int:
     return conditional("test").if_(None).then(success()).else_().then(failed())
Пример #12
0
def multiplier(my_input: float) -> float:
    return (conditional("fractions").if_((my_input >= 0.1)
                                         & (my_input <= 1.0)).then(
                                             double(n=my_input)).else_().then(
                                                 square(n=my_input)))
Пример #13
0
 def my_wf(a: int, b: str) -> (int, str):
     x, y = t1(a=a)
     d = conditional("test1").if_(x == 4).then(t2(a=b)).elif_(x >= 5).then(t2(a=y))
     conditional("test2").if_(x == 4).then(t2(a=b)).elif_(x >= 5).then(t2(a=y)).else_().fail("blah")
     return x, d