Skip to content

Allow jinja templates to be used in task params #7910

Closed

Description

@dimberman

Description

At present when defining an Operator it isn't possible to reference template variables such as ds in the params block.

Enabling this makes it easier to reuse Operators with very similar configurations. An example of this might be a BashOperator which runs a large (possibly external) script that only has a couple of configuration changes used between different runs.

Use case / motivation
For example, you might have something like this:

op = BashOperator(
	task_id = "task",
	bash_command = "do-something.sh {{params.path}}",
        params = {"path": "/path/to/thing/{{ds}}/thing.csv"},
        dag = dag
)

In this case, the bash_command will be expanded to:

  do-something.sh /path/to/thing/{{ds}}/things.csv

But should be expanded to:

  do-something.sh /path/to/thing/2017-06-14/things.csv

Related Issues

Activity

  1. a-jumani commented on Mar 27, 2020

    @a-jumani

    If you don't mind, I'd like to take stab at it. Have been using Airflow for the past few months, would love to contribute.

  2. dmateusp commented on Dec 15, 2020

    @dmateusp
    Contributor

    hi folks! I was looking for this feature and I'm seeing both this issue and 2 PRs closed, but it does not seem resolved?

  3. elephantmetropolis commented on Jun 8, 2023

    @elephantmetropolis

    Hey @dimberman, I am very late to the party but the 2 PRs has been closed and the issue is marked as resolved.
    Is there a reason why jinja template cannot be used within params ? Or is it just waiting for someone to do it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions