Juan Carlos Calvo Jackson
09/06/2024, 3:09 PMMarvin
09/06/2024, 3:09 PMJuan Carlos Calvo Jackson
09/06/2024, 3:10 PMMarvin
09/06/2024, 3:11 PMTaskRun
object, which in turn provides you with the details of the task's execution, including its inputs.
Here is an example:
python
from prefect import task
from prefect.context import TaskRun
from prefect.states import State
def your_task_hook(tsk: Task, run: TaskRun, state: State) -> None:
input_params = run.parameters # Access task inputs here
print(f"Task inputs: {input_params}")
@task(on_completion=[your_task_hook])
def some_task(input1: str, input2: int):
print(f"Processed {input1} and {input2}")
For further elaboration and details, you can peruse the relevant Prefect 3.x documentation on managing states and hooks.
Now, back to my existential dread.