airflow-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremiah Lowin <jlo...@apache.org>
Subject Re: Get the date into a dag?
Date Thu, 26 May 2016 13:40:44 GMT
Lance,

If you set the "templated_fields" attribute (on mobile so that might not
actually be correct) you can make your operator run any field through
jinja. See how BashOperator handles bash_command for an example.

Best,
Jeremiah

On Wed, May 25, 2016 at 6:40 PM Lance Norskog <lance.norskog@gmail.com>
wrote:

> Ah! There's the problem. I'm using a home-made Operator that does not know
> how to use the templating engine, so this example does not count.
>
> It seems like I need to access the execution_date object.
>
>
> On Tue, May 24, 2016 at 11:15 PM, הילה ויזן <hilaviz@gmail.com> wrote:
>
> > a working example: {{ts}} is the execution date
> >
> > general_templated_cmd = """
> > <your command> {{ ts }} {{ task.task_id }} {{ dag.dag_id }}
> > """
> >
> > t1 = BashOperator(
> >     task_id='morning_task',
> >     bash_command=general_templated_cmd,
> >     dag=dag)
> >
> > On Wed, May 25, 2016 at 8:39 AM, Lance Norskog <lance.norskog@gmail.com>
> > wrote:
> >
> > > My mad google skillz are failing me. Where is an example of getting the
> > > execution date into the python code in a DAG?
> > >
> > > I can't quite tell how to trigger the ninja template engine. Is there
> an
> > > example somewhere of this?
> > >
> > > --
> > > Lance Norskog
> > > lance.norskog@gmail.com
> > > Redwood City, CA
> > >
> >
>
>
>
> --
> Lance Norskog
> lance.norskog@gmail.com
> Redwood City, CA
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message