Nate
10/15/2024, 8:34 PMNate
10/15/2024, 11:23 PMMarvin
10/15/2024, 11:23 PMNate
10/15/2024, 11:23 PMMarvin
10/15/2024, 11:23 PMn
and name the task run with the input:
python
from prefect import flow, task
@task(task_run_name=lambda n: f"fibonacci-{n}")
def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a
@flow
def fibonacci_flow(n):
result = fibonacci(n)
print(f"Fibonacci of {n} is {result}")
# Example usage
fibonacci_flow(10)
This code defines a task that computes the Fibonacci number for a given n
, and the task run is named dynamically based on the input value of n
.
For more information, you can check Prefect's flow and task documentation.