elegant-australia-91422
10/18/2022, 4:35 PMconditional
inside a @dynamic
step or should normal python control flow work there? We're seeing a number of issues w/ failing to bind variables in a dynamic workflow using normal `if`/`else` blockstall-lock-23197
conditional
supported within dynamic workflows?glamorous-carpet-83516
10/18/2022, 4:47 PMelegant-australia-91422
10/18/2022, 4:51 PMelegant-australia-91422
10/18/2022, 5:17 PM@dynamic
step (regress
is a boolean)
Logical (and/or/is/not) operations are not supported. Expressions Comparison (<,<=,>,>=,==,!=) or Conjunction (&/|) are supported.Received an evaluated expression with val False in train_estimator.if_
flytekit.conditional("train_estimator")
.if_(regress)
.then(
estimator.train_regressor()
)
.else_()
.then(
estimator.train_classifier()
)
elegant-australia-91422
10/18/2022, 5:17 PMflytekit.conditional
? (I also tried regress == True
as well and that resulted in the same error)elegant-australia-91422
10/18/2022, 5:19 PMglamorous-carpet-83516
10/18/2022, 8:41 PMfrom flytekit import workflow, task, dynamic, conditional
@task
def t1() -> bool:
return True
@task
def t2() -> bool:
return False
@dynamic
def d1() -> bool:
a = t1()
return (
conditional("train_estimator")
.if_(a==True)
.then(t2())
.else_()
.then(t2()))
@workflow
def wf() -> bool:
return d1()
if __name__ == "__main__":
print(wf())
elegant-australia-91422
10/18/2022, 8:41 PMa
is an arg to d1
vs the result of a task?glamorous-carpet-83516
10/18/2022, 8:42 PMregress == True
instead of regress
. Otherwise, it will failglamorous-carpet-83516
10/18/2022, 8:42 PMdoes this work iflet me try it.is an arg toa
vs the result of a task?d1
glamorous-carpet-83516
10/18/2022, 8:47 PMa
is bool instead of promise.glamorous-carpet-83516
10/18/2022, 8:48 PMa
in the if statement must be a promiseelegant-australia-91422
10/18/2022, 8:49 PMPromise.of(my_literal)
(kind of abusing JavaScript notation here but you get the point)?elegant-australia-91422
10/18/2022, 8:49 PMglamorous-carpet-83516
10/18/2022, 9:15 PMHm...ok. Is there a way to do something likewe don’t have that now, but you could add a task to convert it to a promise in @dynamic(kind of abusing JavaScript notation here but you get the point)?Promise.of(my_literal)
@task
def convert_to_promise(a: bool) -> bool:
return a
Or maybe another way, is there a reason preventing this from working w/ both promises and literalsI think we can support pure python type in
_if
as well. we can try to update it in the next release.
For now, to work around this issue, just create a @task to convert it to a promise, sorry.glamorous-carpet-83516
10/18/2022, 9:18 PMbool
or int
in _if
in condition
? currently, we can only use promise in condition.elegant-australia-91422
10/18/2022, 10:05 PMglamorous-carpet-83516
10/18/2022, 10:45 PM