You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airflow.apache.org by weeei he <pe...@gmail.com> on 2016/10/10 09:37:49 UTC

Fwd: Change Airflow Timezone

---------- Forwarded message ----------
From: weeei he <pe...@gmail.com>
Date: 2016-10-10 12:04 GMT+08:00
Subject: Change Airflow Timezone
To: dev-help@airflow.incubator.apache.org
Cc: pyscala@foxmail.com


The display time is UTC  on the  Airflow ui, such as the right top and
Gantt Chart Page.

Can I change the time to Local Time and how should I do?


I temporarily changed the hard code in  *www/templates/admin/master.html* a
nd *www/views.py* .

This is not good solution apparently

/usr/lib/python2.7/site-packages/airflow/www/templates/admin/master.html
 12 <script>
 13     x = new Date()
 14     //MOD
 16     var UTCseconds = x.getTime();//(x.getTime() +
x.getTimezoneOffset()*60*1000);

 18     $("#clock").clock({
 19         "seconds":"false",
 20         "calendar":"false",
 21         "format":"24",
 22         "timestamp":UTCseconds
 23     }).click(function(){
 24         alert('{{ hostname }}');
 25     });
 26     $('span').tooltip();
 27 </script>

/usr/lib/python2.7/site-packages/airflow/www/views.py
1613         data = []
1614         for i, ti in enumerate(tis):
1615             end_date = ti.end_date or datetime.now()
1616             tasks += [ti.task_id]
1617             color = State.color(ti.state)
1619             low = int(ti.start_date.strftime('%s')) * 1000 + 8 * 60 *
60 * 1000
1620             high = int(end_date.strftime('%s')) * 1000 + 8 * 60 * 60 *
1000
1621             data.append({
1622                 'x': i,
1623                 'low': low,
1624                 'high': high,
1625                 'color': color,
1626             })
1628         height = (len(tis) * 25) + 50
1629         session.commit()
1630         session.close()

Re: Change Airflow Timezone

Posted by Maxime Beauchemin <ma...@gmail.com>.
I'd be open in adding a configuration setting for the TZ displayed in the
UI if the default setting stays UTC. I can commit to sponsor & review that
PR personally.

As Sid says, #1633 seems like it's going in that direction but has lost a
bit of steam.

Community, I really recommend writing `+1` comments on PRs that you'd like
to see in master, it can motivate the developer to wrap things up and
committers to review PRs. Beyond that, every committer is very welcomed to
help reviewing code! I'll start a thread about just that right now.

Max

On Mon, Oct 10, 2016 at 1:18 PM, siddharth anand <sa...@apache.org> wrote:

> There is a current limitation that Airflow only runs on GMT/UTC. I believe
> you are asking for a purely cosmetic change to allow the UI to convert date
> times displayed to any TZ. I can't speak to that ability and I expect it's
> easy if we assume that we are always converting from GMT/UTC to a
> display-only timezone that can be selected from a UI drop-down.
>
> On a related note, it would be awesome if someone could take on a change to
> make Airflow TZ aware top-to-bottom and not require it to run strictly in
> UTC/GMT.
>
> I recall vineet-rh started addressing this problem in
> https://github.com/apache/incubator-airflow/pull/1633
>
> Many of us choose to ignore this since all of our systems run in UTC/GMT,
> but I can imagine it's a pain for folks running in legacy data centers
> where the policy is to run in a non-GMT/UTC timezone.
>
> -s
>
> On Mon, Oct 10, 2016 at 2:37 AM, weeei he <pe...@gmail.com> wrote:
>
> > ---------- Forwarded message ----------
> > From: weeei he <pe...@gmail.com>
> > Date: 2016-10-10 12:04 GMT+08:00
> > Subject: Change Airflow Timezone
> > To: dev-help@airflow.incubator.apache.org
> > Cc: pyscala@foxmail.com
> >
> >
> > The display time is UTC  on the  Airflow ui, such as the right top and
> > Gantt Chart Page.
> >
> > Can I change the time to Local Time and how should I do?
> >
> >
> > I temporarily changed the hard code in  *www/templates/admin/master.
> html*
> > a
> > nd *www/views.py* .
> >
> > This is not good solution apparently
> >
> > /usr/lib/python2.7/site-packages/airflow/www/templates/admin/master.html
> >  12 <script>
> >  13     x = new Date()
> >  14     //MOD
> >  16     var UTCseconds = x.getTime();//(x.getTime() +
> > x.getTimezoneOffset()*60*1000);
> >
> >  18     $("#clock").clock({
> >  19         "seconds":"false",
> >  20         "calendar":"false",
> >  21         "format":"24",
> >  22         "timestamp":UTCseconds
> >  23     }).click(function(){
> >  24         alert('{{ hostname }}');
> >  25     });
> >  26     $('span').tooltip();
> >  27 </script>
> >
> > /usr/lib/python2.7/site-packages/airflow/www/views.py
> > 1613         data = []
> > 1614         for i, ti in enumerate(tis):
> > 1615             end_date = ti.end_date or datetime.now()
> > 1616             tasks += [ti.task_id]
> > 1617             color = State.color(ti.state)
> > 1619             low = int(ti.start_date.strftime('%s')) * 1000 + 8 *
> 60 *
> > 60 * 1000
> > 1620             high = int(end_date.strftime('%s')) * 1000 + 8 * 60 *
> 60 *
> > 1000
> > 1621             data.append({
> > 1622                 'x': i,
> > 1623                 'low': low,
> > 1624                 'high': high,
> > 1625                 'color': color,
> > 1626             })
> > 1628         height = (len(tis) * 25) + 50
> > 1629         session.commit()
> > 1630         session.close()
> >
>

Re: Change Airflow Timezone

Posted by siddharth anand <sa...@apache.org>.
There is a current limitation that Airflow only runs on GMT/UTC. I believe
you are asking for a purely cosmetic change to allow the UI to convert date
times displayed to any TZ. I can't speak to that ability and I expect it's
easy if we assume that we are always converting from GMT/UTC to a
display-only timezone that can be selected from a UI drop-down.

On a related note, it would be awesome if someone could take on a change to
make Airflow TZ aware top-to-bottom and not require it to run strictly in
UTC/GMT.

I recall vineet-rh started addressing this problem in
https://github.com/apache/incubator-airflow/pull/1633

Many of us choose to ignore this since all of our systems run in UTC/GMT,
but I can imagine it's a pain for folks running in legacy data centers
where the policy is to run in a non-GMT/UTC timezone.

-s

On Mon, Oct 10, 2016 at 2:37 AM, weeei he <pe...@gmail.com> wrote:

> ---------- Forwarded message ----------
> From: weeei he <pe...@gmail.com>
> Date: 2016-10-10 12:04 GMT+08:00
> Subject: Change Airflow Timezone
> To: dev-help@airflow.incubator.apache.org
> Cc: pyscala@foxmail.com
>
>
> The display time is UTC  on the  Airflow ui, such as the right top and
> Gantt Chart Page.
>
> Can I change the time to Local Time and how should I do?
>
>
> I temporarily changed the hard code in  *www/templates/admin/master.html*
> a
> nd *www/views.py* .
>
> This is not good solution apparently
>
> /usr/lib/python2.7/site-packages/airflow/www/templates/admin/master.html
>  12 <script>
>  13     x = new Date()
>  14     //MOD
>  16     var UTCseconds = x.getTime();//(x.getTime() +
> x.getTimezoneOffset()*60*1000);
>
>  18     $("#clock").clock({
>  19         "seconds":"false",
>  20         "calendar":"false",
>  21         "format":"24",
>  22         "timestamp":UTCseconds
>  23     }).click(function(){
>  24         alert('{{ hostname }}');
>  25     });
>  26     $('span').tooltip();
>  27 </script>
>
> /usr/lib/python2.7/site-packages/airflow/www/views.py
> 1613         data = []
> 1614         for i, ti in enumerate(tis):
> 1615             end_date = ti.end_date or datetime.now()
> 1616             tasks += [ti.task_id]
> 1617             color = State.color(ti.state)
> 1619             low = int(ti.start_date.strftime('%s')) * 1000 + 8 * 60 *
> 60 * 1000
> 1620             high = int(end_date.strftime('%s')) * 1000 + 8 * 60 * 60 *
> 1000
> 1621             data.append({
> 1622                 'x': i,
> 1623                 'low': low,
> 1624                 'high': high,
> 1625                 'color': color,
> 1626             })
> 1628         height = (len(tis) * 25) + 50
> 1629         session.commit()
> 1630         session.close()
>