uranusjr commented on code in PR #63185:
URL: https://github.com/apache/airflow/pull/63185#discussion_r3371389163


##########
airflow-core/src/airflow/dag_processing/bundles/manager.py:
##########
@@ -30,15 +33,42 @@
 from airflow.models.dagbundle import DagBundleModel
 from airflow.models.team import Team
 from airflow.utils.log.logging_mixin import LoggingMixin
-from airflow.utils.session import NEW_SESSION, provide_session
+from airflow.utils.session import NEW_SESSION, create_session, provide_session
 
 if TYPE_CHECKING:
     from collections.abc import Iterable
 
+    from sqlalchemy.engine import CursorResult
     from sqlalchemy.orm import Session
 
 _example_dag_bundle_name = "example_dags"
 
+# Chunk size for the one-time startup repair of unconfigured bundles.
+_REASSIGN_BATCH_SIZE = 1000
+
+
+def _best_bundle_for_fileloc(
+    fileloc: str, descending_bundle_paths: dict[str, Path]
+) -> tuple[str, str] | None:
+    """
+    Return ``(bundle_name, relative_fileloc)`` for the first bundle whose path 
contains ``fileloc``.
+
+    ``descending_bundle_paths`` must be sorted by path length descending so
+    the deepest bundle wins when paths overlap.
+
+    Returns ``None`` when ``fileloc`` is not under any bundle's path.
+    """
+    file_path = Path(os.path.normpath(fileloc))
+    for name, path in descending_bundle_paths.items():
+        try:
+            relative = file_path.relative_to(os.path.normpath(path))

Review Comment:
   Instead of normpath, can pathlib figure things out on its own? It does not 
seem right intuitively these need to be mixed.



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