Simon Rascovsky
04/18/2023, 2:09 AMMarvin
04/18/2023, 2:10 AMprefect.context
to set and access variables within a flow. Here's an example of how to set a variable inside a flow:
python
from prefect import task, Flow
from prefect.engine.signals import SKIP
@task
def set_variable(value):
return value
@task
def use_variable(value):
print(f"Using variable: {value}")
with Flow("example_flow") as flow:
variable_value = set_variable("example_value")
use_variable(variable_value)
flow.run()
In this example, the set_variable
task sets a variable, and the use_variable
task uses the value of that variable. The variable value is passed between tasks using the task's output and input.
Please note that this example is not specific to Prefect version 2.10.4, but the concept should still apply. If you need more information, please let me know, and I'll try to help you further.Nate
04/18/2023, 2:12 AMMarvin
04/18/2023, 2:14 AMprefect.context
to set and access variables within a flow. Here's an example:
python
from prefect import task, Flow
from prefect.engine.signals import SKIP
@task
def set_variable(value):
return value
@task
def use_variable(value):
print(f"Using variable: {value}")
with Flow("example_flow") as flow:
variable_value = set_variable("example_value")
use_variable(variable_value)
flow.run()
In this example, the set_variable
task sets a variable, and the use_variable
task uses the value of that variable. The variable value is passed between tasks using the task's output and input.
Please note that this example is not specific to Prefect 2, but the concept should still apply. If you need more information, please let me know, and I'll try to help you further.