jason810496 commented on code in PR #72442:
URL: https://github.com/apache/airflow/pull/72442#discussion_r3949488527


##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -958,12 +958,10 @@ def _refresh_dag_bundles(self, known_files: dict[str, 
set[DagFileInfo]]):
 
     def _find_files_in_bundle(self, bundle: BaseDagBundle) -> list[Path]:
         """Get relative paths for dag files from bundle dir."""
-        # Build up a list of Python files that could contain DAGs
         self.log.info("Searching for files in %s at %s", bundle.name, 
bundle.path)
-        rel_paths = [
-            Path(x).relative_to(bundle.path)
-            for x in list_py_file_paths(bundle.path, 
safe_mode=self.dag_discovery_safe_mode)
-        ]
+        importer_registry = bundle.importer_registry
+        dag_files = importer_registry.list_dag_files(bundle.path, 
safe_mode=self.dag_discovery_safe_mode)

Review Comment:
   I feel the whole `_find_files_in_bundle` method should be replaced with 
`registry.list_dag_files`.
   IIUC, the `registry` should contain all the importer respecting each level 
(bundle, dag-processor, global), so `registry.list_dag_files` should give out 
all the possible and valid file path.



##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -958,12 +958,10 @@ def _refresh_dag_bundles(self, known_files: dict[str, 
set[DagFileInfo]]):
 
     def _find_files_in_bundle(self, bundle: BaseDagBundle) -> list[Path]:
         """Get relative paths for dag files from bundle dir."""
-        # Build up a list of Python files that could contain DAGs
         self.log.info("Searching for files in %s at %s", bundle.name, 
bundle.path)
-        rel_paths = [
-            Path(x).relative_to(bundle.path)
-            for x in list_py_file_paths(bundle.path, 
safe_mode=self.dag_discovery_safe_mode)
-        ]
+        importer_registry = bundle.importer_registry
+        dag_files = importer_registry.list_dag_files(bundle.path, 
safe_mode=self.dag_discovery_safe_mode)

Review Comment:
   I feel the whole `_find_files_in_bundle` method should be replaced with 
`registry.list_dag_files`.
   IIUC, the `registry` should contain all the importer respecting each level 
(bundle, dag-processor, global), so `registry.list_dag_files` should give out 
the possible and valid file path.



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