fblaze f
12/31/2020, 5:40 PM#!/usr/bin/python3
from datetime import datetime
from prefect import task, Flow, Parameter, context, case
from prefect.utilities.debug import is_serializable
logger = context.get("logger")
timestamp = datetime.now().strftime("%Y-%m-%dT%H-%M-%S")
@task
def print_timestamp():
<http://logger.info|logger.info>(timestamp)
with Flow("Test") as flow:
print_timestamp()
serializable = is_serializable(flow)
if serializable:
flow.register(project_name="Default",
idempotency_key=flow.serialized_hash())
flow.run()
Attached screenshot from two runs. As you could see, the value of the global parameter timestamp
hasn't changedDylan
Dylan
Dylan
@task
def create_timestamp():
return datetime.now().strftime("%Y-%m-%dT%H-%M-%S")
@task
def print_timestamp(timestamp):
<http://logger.info|logger.info>(timestamp)
with Flow("test") as flow:
ts = generate_timestamp()
print_timestamp(ts)
Dylan
Dylan
fblaze f
12/31/2020, 5:53 PMDylan