Tobias Schmidt
10/11/2019, 7:16 AMemre
10/11/2019, 7:27 AMJinjaTemplate(Task)
only accepts generic task initialization **kwargs
, not your formatting params.
Formatting params, i.e. **format_kwargs
are passed strictly at flow runtime, in other words flow.run()
Tobias Schmidt
10/11/2019, 8:25 AMemre
10/11/2019, 8:36 AMpython
from prefect import Flow
from prefect.tasks.templates import JinjaTemplate
message = '''
Hi {{name}}! Welcome to Prefect. Today is {{today}}.
'''
msg_task = JinjaTemplate(name="message body", template=message)
with Flow("string-template") as flow:
output = msg_task(name="Marvin")
flow_state = flow.run()
print(flow_state.result[output].result)
# Hi Marvin! Welcome to Prefect. Today is 2019-08-28.
Tobias Schmidt
10/11/2019, 8:53 AMJinjaTemplate()
but how to reference variables from the context, which the docs say is possibleemre
10/11/2019, 9:05 AM{{today}}
, since the today key is provided by the prefect context.{{task_name}}
or {{scheduled_start_time}}