You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Lee-W (via GitHub)" <gi...@apache.org> on 2024/08/28 11:03:11 UTC

[PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Lee-W opened a new pull request, #41828:
URL: https://github.com/apache/airflow/pull/41828

   …
   
   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W merged PR #41828:
URL: https://github.com/apache/airflow/pull/41828


-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #41828:
URL: https://github.com/apache/airflow/pull/41828#discussion_r1738026433


##########
airflow/models/dag.py:
##########
@@ -3706,7 +3706,11 @@ def calculate_dagrun_date_fields(
 
     @provide_session
     def get_dataset_triggered_next_run_info(self, *, session=NEW_SESSION) -> dict[str, int | str] | None:
-        if self.dataset_expression is None:
+        # If an alias is unresolved, we don't have the next_run_info to get
+        if (
+            self.dataset_expression is None
+            and self.timetable_summary != DatasetTriggeredTimetable.UNRESOLVED_ALIAS_SUMMARY

Review Comment:
   If that's the case, I think we probably need to add an additional boolean column here then?



-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on PR #41828:
URL: https://github.com/apache/airflow/pull/41828#issuecomment-2363014873

   > Should this have a test?
   
   sounds good. just added it. will merge this one once CI passed


-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #41828:
URL: https://github.com/apache/airflow/pull/41828#discussion_r1738005080


##########
airflow/models/dag.py:
##########
@@ -3706,7 +3706,11 @@ def calculate_dagrun_date_fields(
 
     @provide_session
     def get_dataset_triggered_next_run_info(self, *, session=NEW_SESSION) -> dict[str, int | str] | None:
-        if self.dataset_expression is None:
+        # If an alias is unresolved, we don't have the next_run_info to get
+        if (
+            self.dataset_expression is None
+            and self.timetable_summary != DatasetTriggeredTimetable.UNRESOLVED_ALIAS_SUMMARY

Review Comment:
   Or maybe just a flag on Timetable altogether. We have things like `can_be_scheduled`. Maybe a `has_resolved_dataset` would be reasonable?



-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #41828:
URL: https://github.com/apache/airflow/pull/41828#discussion_r1738024514


##########
airflow/models/dag.py:
##########
@@ -3706,7 +3706,11 @@ def calculate_dagrun_date_fields(
 
     @provide_session
     def get_dataset_triggered_next_run_info(self, *, session=NEW_SESSION) -> dict[str, int | str] | None:
-        if self.dataset_expression is None:
+        # If an alias is unresolved, we don't have the next_run_info to get
+        if (
+            self.dataset_expression is None
+            and self.timetable_summary != DatasetTriggeredTimetable.UNRESOLVED_ALIAS_SUMMARY

Review Comment:
   The main problem is I don’t think it is a good idea to do this `timetable_summary` check at all.



-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #41828:
URL: https://github.com/apache/airflow/pull/41828#discussion_r1738020382


##########
airflow/models/dag.py:
##########
@@ -3706,7 +3706,11 @@ def calculate_dagrun_date_fields(
 
     @provide_session
     def get_dataset_triggered_next_run_info(self, *, session=NEW_SESSION) -> dict[str, int | str] | None:
-        if self.dataset_expression is None:
+        # If an alias is unresolved, we don't have the next_run_info to get
+        if (
+            self.dataset_expression is None
+            and self.timetable_summary != DatasetTriggeredTimetable.UNRESOLVED_ALIAS_SUMMARY

Review Comment:
   will extracting this condition as a `has_resolved_dataset` property a bit better?



##########
airflow/models/dag.py:
##########
@@ -3706,7 +3706,11 @@ def calculate_dagrun_date_fields(
 
     @provide_session
     def get_dataset_triggered_next_run_info(self, *, session=NEW_SESSION) -> dict[str, int | str] | None:
-        if self.dataset_expression is None:
+        # If an alias is unresolved, we don't have the next_run_info to get
+        if (
+            self.dataset_expression is None
+            and self.timetable_summary != DatasetTriggeredTimetable.UNRESOLVED_ALIAS_SUMMARY

Review Comment:
   I just look into it a bit. It looks like `get_dataset_triggered_next_run_info` is part of `DagModel` instead and I think we probably don't really want to create a new column `has_resolved_dataset`



-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #41828:
URL: https://github.com/apache/airflow/pull/41828#discussion_r1738355302


##########
airflow/models/dag.py:
##########
@@ -3706,7 +3706,11 @@ def calculate_dagrun_date_fields(
 
     @provide_session
     def get_dataset_triggered_next_run_info(self, *, session=NEW_SESSION) -> dict[str, int | str] | None:
-        if self.dataset_expression is None:
+        # If an alias is unresolved, we don't have the next_run_info to get
+        if (
+            self.dataset_expression is None
+            and self.timetable_summary != DatasetTriggeredTimetable.UNRESOLVED_ALIAS_SUMMARY

Review Comment:
   After a second thought, we probably don't need to make things complicated. Just return None if no _dataset_triggered_next_run_info can be retrieved (when there're no dataset to join)



-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #41828:
URL: https://github.com/apache/airflow/pull/41828#discussion_r1738004208


##########
airflow/models/dag.py:
##########
@@ -3706,7 +3706,11 @@ def calculate_dagrun_date_fields(
 
     @provide_session
     def get_dataset_triggered_next_run_info(self, *, session=NEW_SESSION) -> dict[str, int | str] | None:
-        if self.dataset_expression is None:
+        # If an alias is unresolved, we don't have the next_run_info to get
+        if (
+            self.dataset_expression is None
+            and self.timetable_summary != DatasetTriggeredTimetable.UNRESOLVED_ALIAS_SUMMARY

Review Comment:
   This part should probably be a bit more robust… maybe add a couple of flags on `DatasetTriggeredTimetable` and use that instead?



-- 
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


Re: [PR] fix(dag): avoid getting dataset next run info for unresolved dataset alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #41828:
URL: https://github.com/apache/airflow/pull/41828#discussion_r1738008481


##########
airflow/models/dag.py:
##########
@@ -3706,7 +3706,11 @@ def calculate_dagrun_date_fields(
 
     @provide_session
     def get_dataset_triggered_next_run_info(self, *, session=NEW_SESSION) -> dict[str, int | str] | None:
-        if self.dataset_expression is None:
+        # If an alias is unresolved, we don't have the next_run_info to get
+        if (
+            self.dataset_expression is None
+            and self.timetable_summary != DatasetTriggeredTimetable.UNRESOLVED_ALIAS_SUMMARY

Review Comment:
   yep, we could do that. `has_resolved_dataset` sounds good



-- 
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