Skip to content

Add support for .jinja2 extensions - #8616

Closed
oripwk wants to merge 5 commits into
apache:masterfrom
oripwk:8603
Closed

oripwk wants to merge 5 commits into
apache:masterfrom
oripwk:8603

Conversation

@oripwk

@oripwk oripwk commented Apr 28, 2020 •

Copy link
Copy Markdown
Contributor

This PR closes #8603, which seeks adding support for .jinja2 for file templates across the project.

It defines a new property for BaseOperator which is a list containing .jinja2 (and possibly other extensions if someone wants to add in the future), and whenever template_ext is not empty, the list is combined with it to produce a definite list of extensions, which is used throughout the class.


Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Unit tests coverage for changes (not needed for documentation changes)
  • Target Github ISSUE in description if exists
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

@oripwk

oripwk commented Apr 29, 2020 •

Copy link
Copy Markdown
Contributor Author

@mik-laj this is the proposed solution.
The only remaining issue is how we update the docs, since there are dozens of operators whose docs we need to update with "also supports .jinja2 extensions". Also people creating new operators should not forget adding this.

Do you know of any good way of doing it?

@mik-laj

mik-laj commented Apr 29, 2020

Copy link
Copy Markdown
Member

@oripwk I think you just need to add this information in the base class and check that the documentation in the * .rst files is up-to-date.

@potiuk

potiuk commented Apr 29, 2020

Copy link
Copy Markdown
Member

Agree with @mik-laj I think this should be implemented as common feature - so it should be just explained in the same place where we already explain the general jinija templates stuff.

@oripwk

oripwk commented Apr 29, 2020

Copy link
Copy Markdown
Contributor Author

I agree, although there's a minor issue with the docs of the individual fields i.e. in BashOperator the bash_command doc says:

"The command, set of commands or reference to a bash script (must be ‘.sh’) to be executed. (templated)"

So it will stay as is. The question is if it's fine.

@potiuk

potiuk commented Apr 29, 2020 •

Copy link
Copy Markdown
Member

I think we might use the opportunity to improve the docs slightly (and globally). If we go with my proposed rule (.sh and .sh.jinja2 for example in Bash), then we could automate the generation of such documentation snippet. The extensions supported will remain as they are in the operator definitions, and we could write a small plugin to generate the documentation and list supported extensions and remove manually entered documentation for that. We've done things like that before.

@ashb

ashb commented May 1, 2020

Copy link
Copy Markdown
Member

As discussed on the dev list, thist might be an opportunity to have, .sh. not be templated, but .sh.jinja2 be templated.

Right now it's not possible to have the script/command etc. live in an external file but not be templated. And that is occasionally annoying.

@oripwk

oripwk commented May 2, 2020

Copy link
Copy Markdown
Contributor Author

@ashb

Do we want to do a separate solution for v1.10 and v2.0? (in v.1.10 just render all *.sh and *.sh.jinja2 but in v.2.0 render only *.sh.jinja2 but not *.sh)?

Or to implement only the v2.0 solution?

@stale

stale Bot commented Jun 17, 2020

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Jun 17, 2020
@stale stale Bot closed this Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider supporting .jinja2 extensions across the project

4 participants