pateash edited a comment on pull request #16931:
URL: https://github.com/apache/airflow/pull/16931#issuecomment-883062473


   > > 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.
   
   @ashb @potiuk @kaxil @uranusjr 
   Please correct me If I am wrong here,
   
   As far as I know we use DagModel object to render dag information in UI,
   so for timeline even if we use something like an Enriched Python Object in 
the future, we will still need to store that information in Database/DagModel.
   
   ```python
   class MyCustomTimetable(Timetable):
       ...
   
   dag = DAG(
       ...,
       timetable=MyCustomTimetable(),
   )
   ```
   
   So, while rendering in UI, we will need that information in DagModel and we 
can't use **DAG.timetable**.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to