Deceivious
03/24/2023, 8:11 AMwith_options
methods?Tim Galvin
03/24/2023, 8:14 AMdef my_func(a):
return a*100
task_my_func = task(my_func)
task_my_func
in my prefect code that it is delayed and should be called as such.
Otherwise, I believe that a task
decorated function can still be access. It is something like
task_my_func.fn
which might be useful for your unit testsDeceivious
03/24/2023, 9:59 AMwith_options
from unittest import mock
import logging
def prefect_task_patcher():
def wrapper(*_args, **_kwargs):
class PrefectTaskPatcher:
def __call__(self, *call_args, **call_kwargs):
return self.fn(*call_args, **call_kwargs)
def __init__(self, fn):
self.fn = fn
def with_options(self, *_options_args, **_options_kwargs):
return self
return PrefectTaskPatcher
return wrapper
mock_task = mock.patch("prefect.task", new_callable=prefect_task_patcher)
mock_logs = mock.patch("prefect.get_run_logger", returns=logging)