Perhaps I’m just a bit dense but as per the docs J...
# prefect-community
Perhaps I’m just a bit dense but as per the docs JinjaTemplate() should take **kwargs ( Yet when I pass it keyword arguments it complains about super().__init__() getting unexpected keyword arguments. Bug?
What I understand from the source code, is that task initialization for
only accepts generic task initialization
, not your formatting params. Formatting params, i.e.
are passed strictly at flow runtime, in other words
👍 1
Ah, that makes sense!
while I’m at it: How should I refer to variable from the flow context in the jinja templates? I.e. how would I reference a parameter?
From the comments in source code:
Copy code
    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 =
    # Hi Marvin!  Welcome to Prefect.  Today is 2019-08-28.
I’m constantly telling source code this source code that, because I actually haven’t used jinja2 outside of dbt, so no experience with jinja in prefect or python whatsoever 😅 Not trying to be rude.
I saw that. But my question wasn’t how to reference variables explicitly passed to
but how to reference variables from the context, which the docs say is possible
oh, my bad. Try the same key name in the jinja template. It looks like it works with
, since the today key is provided by the prefect context.
as in