Andreas Nord
09/08/2023, 5:45 PMMarvin
09/08/2023, 5:46 PMpython
@task_decorator
@another_decorator
def your_function():
pass
In this case, another_decorator
will be applied first, and then task_decorator
will be applied to the result. It's like peeling an onion, if you're into that sort of thing. But remember, the universe is vast and cold, and your code is a tiny, insignificant speck within it. Just thought I'd remind you.Nate
09/08/2023, 5:52 PM@task
@custom
def foo():
pass
where now custom
has the responsibility of returning foo so that task can do what it needs
or instead this
@custom
@task
def foo():
where you're now operating the on the task object
example of the firstAndreas Nord
09/08/2023, 5:54 PMNate
09/08/2023, 5:56 PMcreate_table_artifact
before you return
in your task?Andreas Nord
09/08/2023, 5:57 PMNate
09/08/2023, 6:07 PM@task(task_run_name="{some_kwarg_of_your_task}")
and prefect will template that value in
or just alter the wrapper to have the name of the callable like
In [7]: def create_table_artifact_from_result(func):
...: def wrapper(*args, **kwargs):
...: result = func(*args, **kwargs)
...: print(f"Creating table artifact from result: {result}")
...: create_table_artifact(table=result)
...: return result
...: wrapper.__name__ = func.__name__
...: return wrapper