You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/07/19 08:50:18 UTC

[GitHub] [airflow] uranusjr commented on pull request #16931: #16692 show cron description in UI

uranusjr commented on pull request #16931:
URL: https://github.com/apache/airflow/pull/16931#issuecomment-882368742


   > we can create a base class like DagBase which will have the common properties, but I think it's a overkill but a better approach so applying this.
   
   The problem is, we are planning to make `timetable` directly customisable by the user like this:
   
   ```python
   class MyCustomTimetable(Timetable):
       ...
   
   dag = DAG(
       ...,
       timetable=MyCustomTimetable(),
   )
   ```
   
   and this can be any rich Python object. So while the `BaseDag` approach works right now, it will not work once the timetable instance is not calculated directly from `schedule_interval`. So we need to access the original `DAG.timetable` property instead.
   
   This is actually not difficult at all. All the DAG objects are in `current_app.dag_bag`, so you can add this to the template’s context:
   
   ```python
   'dag_timetable': current_app.dag_bag.get_dag(dag.dag_id).timetable
   ```
   
   But it is pretty cumbersome to add this for *all* views that render `dag.html` (because this is a base template inherited by many), and even more difficult to do for `dags.html`. So I’m thinking we probably need to expose `current_app.dag_bag` in the template instead, maybe by poplating `dag_bag` into the global Jinja environment (with e.g. `current_app.jinja_env.add_template_global()`), or something else. I’m unfortuantely not familiar with Flask enough to know the best practice.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org