Len Strnad
05/22/2024, 3:26 PMfrom flytekit import task
@task
def f(x: int) -> int:
if x > 0:
return x + 2
else:
raise ValueError("x must be positive")
def test_f_raises():
with pytest.raises(ValueError):
f(-1)
Will fail since flyte doesn’t seem to surface the ValueError, but instead shows a SystemExit. Any tips to bypass this type of behavior? I can easily abstract the logic out of f
and test that python function independently from task f
, but for more experimental workflows, we tend to avoid these decoupling abstractions.Niels Bantilan
05/22/2024, 3:30 PMf.task_function
Niels Bantilan
05/22/2024, 3:31 PMLen Strnad
05/22/2024, 3:35 PMdef test_f_raises():
with pytest.raises(ValueError):
_f = f.task_function
_f(-1)
works!Len Strnad
05/22/2024, 3:36 PM.task_function
propertyYee
Yee
Charlie Moriarty
05/29/2024, 10:34 AMNiels Bantilan
05/29/2024, 12:37 PMCharlie Moriarty
05/29/2024, 12:46 PMf
, which previously passed using:
def test_f_raises():
with pytest.raises(ValueError):
f(-1)
Now in order to pass in 1.12.0
these have all been converted to:
def test_f_raises():
with pytest.raises(ValueError):
_f = f.task_function
_f(-1)
Niels Bantilan
05/29/2024, 4:09 PMCharlie Moriarty
05/30/2024, 1:21 PMEduardo Apolinario (eapolinario)
05/30/2024, 9:05 PMCharlie Moriarty
05/31/2024, 3:57 PM