Git Product home page Git Product logo

Comments (5)

LamaAni avatar LamaAni commented on June 27, 2024

Hi, thank you for your comment. I was considering implementing exacly this for a while since it seems to be required, but have not had the time. Since I have not, I would certanly accept a PR where we can collaborate on the basis of this idea.

I was thinking something along the lines of input arguments as,

  1. enable_jijna_in_string_body (bool), default TRUE. Notice the string in the name so it will not be confused with dict input.
  2. jinja_context (dict), extended by task default options (like airflow jinja).

And methods:

  1. parse_jinja_body (only runs if enable_jijna_in_string_body is True).

To be added @ line 94 something like,

        body = body or self._read_body(
            resolve_relative_path(body_filepath or DEFAULT_EXECUTION_OBJECT_PATHS[DEFAULT_EXECTION_OBJECT], 2)
        )

        assert body is not None and (isinstance(body, (dict, str))), ValueError(
            "body must either be a yaml string or a dict"
        )

        if isinstance(body, str) and self.enable_jijna_in_string_body:
            body = self.parse_body_jinja(body)

Requirements:

  1. Support jinja2 only.
  2. Support airflow core jinja arguments.
  3. Support jinja_context (overrides core airflow jinja arguments if they exist, i.e. dict.update)

What do you think?

from kubernetesjoboperator.

odesenfans avatar odesenfans commented on June 27, 2024

The best solution would be to use Go templates directly, but jinja2 should do the trick. I don't think there's a good implementation of Go templates in Python so far. I'll take a look tomorrow. :)

from kubernetesjoboperator.

LamaAni avatar LamaAni commented on June 27, 2024

Hum, I would actially like to stick with Jinja since other operators are integrated with it.
Added support see PR: #27

from kubernetesjoboperator.

LamaAni avatar LamaAni commented on June 27, 2024

Can this be closed?

from kubernetesjoboperator.

odesenfans avatar odesenfans commented on June 27, 2024

Yes! Closing it then giving it a try right away.

from kubernetesjoboperator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.