Hank Huang
07/18/2023, 2:38 AMdef is_None(self):
return ComparisonExpression(self, ComparisonOps.EQ, None)
def is_None(self):
return self == None
Here is my tested workflow
@task(limits=Resources(mem="1Gi",cpu="1"))
def none_func()->str:
return f"the input is None"
@task(limits=Resources(mem="1Gi",cpu="1"))
def not_none_func(obj)->str:
return f"the input {obj} is not None"
@task(limits=Resources(mem="1Gi",cpu="1"))
def get_none() -> None:
return None
@task(limits=Resources(mem="1Gi",cpu="1"))
def get_int() -> int:
return 100
@workflow
def none_wf2()->str:
my_input = get_int()
return (
conditional("testing_none")
.if_(my_input.is_None())
.then(none_func())
.else_()
.then(not_none_func(obj=my_input))
)
Thanks for the response!Jay Ganbat
07/18/2023, 3:11 AMis_(None)
here is the source code
def is_(self, v: bool) -> ComparisonExpression:
return ComparisonExpression(self, ComparisonOps.EQ, v)
def is_false(self) -> ComparisonExpression:
return self.is_(False)
def is_true(self):
return self.is_(True)
Hank Huang
07/18/2023, 3:14 AMJay Ganbat
07/18/2023, 3:21 AMOptional[int]
in your get_int method since it returns Int so im not sure it can be none according to typePromise
object, the way its called before is you are calling a custom method so i dont think it can be called on Promise objectHank Huang
07/18/2023, 3:29 AMJay Ganbat
07/18/2023, 3:29 AMis_(None)
is_None()
method 🤔my_input.is_(None)
my_input
will be Promise type during registrationHank Huang
07/18/2023, 3:32 AM@workflow
def none_wf2()->str:
my_input = get_others()
method_source = inspect.getsource(my_input.is_None)
print(method_source)
return (
conditional("testing_none")
.if_(my_input.is_(None))
.then(none_func())
.else_()
.then(not_none_func(obj=my_input))
)
Jay Ganbat
07/18/2023, 3:33 AMHank Huang
07/18/2023, 3:34 AMJay Ganbat
07/18/2023, 3:42 AMget_others
same as get_int
Hank Huang
07/18/2023, 3:44 AMJay Ganbat
07/18/2023, 3:45 AMnone_func()
its returning None
but your workflow outputs str
Hank Huang
07/18/2023, 3:48 AM@task(limits=Resources(mem="1Gi",cpu="1"))
def none_func()->Optional[str]:
return f"the input is None"
@task(limits=Resources(mem="1Gi",cpu="1"))
def not_none_func(obj)->Optional[str]:
return f"the input {obj} is not None"
@task(limits=Resources(mem="1Gi",cpu="1"))
def get_none() -> None:
return None
@task(limits=Resources(mem="1Gi",cpu="1"))
def get_int() -> Optional[int]:
return 100
@workflow
def none_wf2()->str:
my_input = get_int()
return (
conditional("testing_none")
.if_(my_input.is_(True))
.then(none_func())
.else_()
.then(not_none_func(obj=my_input))
)
I think the problem is where I call my_input.is_(None)
=> that the part cause the error.Jay Ganbat
07/18/2023, 3:51 AMnone_wf2() -> Optional[str]
but i actually never tried to explicitly check for None
i usually just return get_int()
or any conditional check to return bool and use is_true() on itHank Huang
07/18/2023, 4:02 AMJay Ganbat
07/18/2023, 4:05 AMdef is_none(myinput) -> bool:
return some_conditional_method(myinput)
def my_wf()...
result = is_none(in_spec_path=in_spec_path)
out_aligned_bam_gs, out_metrics = (
conditional("MYWF")
.if_(result.is_true())
.then(
call_first_task()
)
.else_()
.then(
call_the_other_task()
)
)
Hank Huang
07/18/2023, 4:16 AMJay Ganbat
07/18/2023, 4:35 AMHank Huang
07/18/2023, 4:40 AM