ultrabug commented on a change in pull request #2460: [AIRFLOW-1424] make the 
next execution date of DAGs visible
URL: https://github.com/apache/incubator-airflow/pull/2460#discussion_r231150858
 
 

 ##########
 File path: airflow/models.py
 ##########
 @@ -3055,6 +3055,37 @@ def latest_execution_date(self):
         session.close()
         return execution_date
 
+    @property
+    def next_run_date(self):
+        """
+        Returns the next run date for which the dag will be scheduled
+        """
+        next_run_date = None
+        if not self.latest_execution_date:
+            # First run
+            task_start_dates = [t.start_date for t in self.tasks]
+            if task_start_dates:
+                next_run_date = self.normalize_schedule(min(task_start_dates))
+        else:
+            next_run_date = self.following_schedule(self.latest_execution_date)
+        return next_run_date
+
+    @property
+    def next_execution_date(self):
+        """
+        Returns the next execution date at which the dag will be scheduled by
 
 Review comment:
   This is exactly the logic I've followed and you can see that my proposed 
implementation is based on the scheduler's jobs.py code indeed
   
   I can shrink the next_run_date function into one to make it simple tho 
indeed, gonna update
   
   @XD-DENG as you see the scheduler does otherwise and having None as a result 
looks strange to me since there's always a **period end** at which the 
scheduler itself will execute the DAG (if it has a start_date that is).
   
   So it's not because no previous execution has happened that there won't be 
any right. And the scheduler code above shows how it does it.
   
   Still, @XD-DENG I think your link has a nice example and I'll make sure to 
validate the fact that this PR behaves exactly as the documentation says. Sound 
good to you?   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to