Trevor Kramer
10/21/2022, 6:07 PMfrom prefect import flow, get_run_logger, task
from prefect.testing.utilities import prefect_test_harness
def test_flow():
@task
def _add(x: int, y: int) -> int:
get_run_logger().info(f"Adding {x} + {y} in task")
return x + y
@flow(persist_result=True, result_storage="s3/mldc-result-storage", result_serializer="json")
def add(x: int, y: int) -> int:
get_run_logger().info(f"Adding {x} + {y}")
result = _add(x, y)
return result
with prefect_test_harness():
assert add(5, 6) == 11
Ryan Peden
10/21/2022, 8:39 PMwith_options
to override that setting. In the sample you posted, the last few lines could change to:
with prefect_test_harness():
test_add = add.with_options(result_storage=None)
assert test_add(5, 6) == 11