Re: [PR] Dag processor consumes DagPriorityParsingRequest when relative file l… [airflow]

2025-06-10 Thread via GitHub


jedcunningham commented on code in PR #48659:
URL: https://github.com/apache/airflow/pull/48659#discussion_r2138051918


##
airflow-core/src/airflow/migrations/versions/0069_3_0_0_make_relative_fileloc_nullable_for_.py:
##
@@ -0,0 +1,52 @@
+#
+# 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.
+
+"""
+make relative_fileloc nullable for reserialized all bundles.

Review Comment:
   ```suggestion
   Make DagPriorityParsingRuquest.relative_fileloc nullable.
   ```
   
   nit



##
airflow-core/src/airflow/models/dagbag.py:
##
@@ -685,12 +685,22 @@ class DagPriorityParsingRequest(Base):
 # Note: Do not depend on fileloc pointing to a file; in the case of a
 # packaged DAG, it will point to the subpath of the DAG within the
 # associated zip.
-relative_fileloc = Column(String(2000), nullable=False)
+relative_fileloc = Column(String(2000), nullable=True)
 
-def __init__(self, bundle_name: str, relative_fileloc: str) -> None:
+def __init__(self, bundle_name: str, relative_fileloc: str = "") -> None:

Review Comment:
   ```suggestion
   def __init__(self, bundle_name: str, relative_fileloc: str | None = 
None) -> None:
   ```
   
   If we are allowing nullable, lets actually use nulls then - otherwise we 
don't really need to alter the table in the first place.



##
airflow-core/src/airflow/dag_processing/manager.py:
##
@@ -413,20 +413,35 @@ def _queue_requested_files_for_parsing(self) -> None:
 
 @provide_session
 def _get_priority_files(self, session: Session = NEW_SESSION) -> 
list[DagFileInfo]:
-files: list[DagFileInfo] = []
+files: set[DagFileInfo] = set()
 bundles = {b.name: b for b in self._dag_bundles}
 requests = session.scalars(
 
select(DagPriorityParsingRequest).where(DagPriorityParsingRequest.bundle_name.in_(bundles.keys()))
 )
 for request in requests:
 bundle = bundles[request.bundle_name]
-files.append(
-DagFileInfo(
-rel_path=Path(request.relative_fileloc), 
bundle_name=bundle.name, bundle_path=bundle.path
+if request.parse_whole_folder():
+# If relative_fileloc is null, get all files from DagModel
+dag_files = session.scalars(

Review Comment:
   We probably should refresh the bundle and [relist the dags from 
disk](https://github.com/apache/airflow/blob/bf0bfe9dc1f3812989acfe6ed7118acf9ba5b586/airflow-core/src/airflow/dag_processing/manager.py#L579)
 instead of querying the db.
   
   I think we can just refresh here, relist, and add, but it'd be worth giving 
it a bit more thought to make sure we aren't impacting other stuff by doing so.



##
airflow-core/src/airflow/models/dagbag.py:
##
@@ -685,12 +685,22 @@ class DagPriorityParsingRequest(Base):
 # Note: Do not depend on fileloc pointing to a file; in the case of a
 # packaged DAG, it will point to the subpath of the DAG within the
 # associated zip.
-relative_fileloc = Column(String(2000), nullable=False)
+relative_fileloc = Column(String(2000), nullable=True)
 
-def __init__(self, bundle_name: str, relative_fileloc: str) -> None:
+def __init__(self, bundle_name: str, relative_fileloc: str = "") -> None:
 super().__init__()
 self.bundle_name = bundle_name
 self.relative_fileloc = relative_fileloc
 
+def parse_whole_folder(self) -> bool:
+"""
+Check if this request should parse the whole folder based on 
relative_fileloc.
+
+Returns:
+bool: True if relative_fileloc is None, indicating the whole 
folder should be parsed,
+ False otherwise.
+"""
+return self.relative_fileloc == ""

Review Comment:
   ```suggestion
   return self.relative_fileloc is None
   ```



-- 
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-unsubscr...@airflow.apache.org

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



Re: [PR] Dag processor consumes DagPriorityParsingRequest when relative file l… [airflow]

2025-06-10 Thread via GitHub


pierrejeambrun commented on PR #48659:
URL: https://github.com/apache/airflow/pull/48659#issuecomment-2958809534

   up.


-- 
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-unsubscr...@airflow.apache.org

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



Re: [PR] Dag processor consumes DagPriorityParsingRequest when relative file l… [airflow]

2025-04-30 Thread via GitHub


shubham-pyc commented on PR #48659:
URL: https://github.com/apache/airflow/pull/48659#issuecomment-2842902164

   @pierrejeambrun fixed the CI 


-- 
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-unsubscr...@airflow.apache.org

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



Re: [PR] Dag processor consumes DagPriorityParsingRequest when relative file l… [airflow]

2025-04-22 Thread via GitHub


shubham-pyc commented on PR #48659:
URL: https://github.com/apache/airflow/pull/48659#issuecomment-2822925188

   @pierrejeambrun resolved conflicts


-- 
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-unsubscr...@airflow.apache.org

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



Re: [PR] Dag processor consumes DagPriorityParsingRequest when relative file l… [airflow]

2025-04-03 Thread via GitHub


shubham-pyc commented on PR #48659:
URL: https://github.com/apache/airflow/pull/48659#issuecomment-2774915878

   @jedcunningham  please take a look at this one.


-- 
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-unsubscr...@airflow.apache.org

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



Re: [PR] Dag processor consumes DagPriorityParsingRequest when relative file l… [airflow]

2025-04-02 Thread via GitHub


shubham-pyc commented on code in PR #48659:
URL: https://github.com/apache/airflow/pull/48659#discussion_r2024305714


##
airflow-core/src/airflow/dag_processing/manager.py:
##
@@ -407,20 +407,35 @@ def _queue_requested_files_for_parsing(self) -> None:
 
 @provide_session
 def _get_priority_files(self, session: Session = NEW_SESSION) -> 
list[DagFileInfo]:
-files: list[DagFileInfo] = []
+files: set[DagFileInfo] = set()

Review Comment:
   I changed this from a list to a set to ensure uniqueness. There may be cases 
where a DagPriorityParsingRequest is triggered for both a specific file and a 
bundle, potentially causing duplicates. Using a set guarantees that each file 
appears only once.



-- 
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-unsubscr...@airflow.apache.org

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



Re: [PR] Dag processor consumes DagPriorityParsingRequest when relative file l… [airflow]

2025-04-02 Thread via GitHub


shubham-pyc commented on PR #48659:
URL: https://github.com/apache/airflow/pull/48659#issuecomment-2771539852

   Still work in progress test cases are yet to come


-- 
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-unsubscr...@airflow.apache.org

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