henry3260 commented on code in PR #77717:
URL: https://github.com/apache/airflow/pull/77717#discussion_r4722854799
##########
airflow-core/src/airflow/cli/commands/dag_command.py:
##########
@@ -672,9 +673,26 @@ def dag_details(args, *, session: Session = NEW_SESSION):
@provide_session
def dag_list_import_errors(args, *, session: Session = NEW_SESSION) -> None:
"""Display dags with import errors on the command line."""
- data = []
+ data: list[dict[str, str]] = []
- if args.local:
+ if args.dag_path:
+ if args.bundle_name:
+ raise SystemExit("--dag-path cannot be used with --bundle-name")
+
+ path = Path(args.dag_path).resolve()
+ if path.is_file():
+ bundle_path = path.parent
+ elif path.is_dir():
+ bundle_path = path
+ else:
+ raise SystemExit(f"Dag path {path} does not exist or is not a file
or directory.")
+
+ path_dagbag = BundleDagBag(path, bundle_path=bundle_path)
Review Comment:
nit: a file that safe mode skips, or one with an unsupported extension,
returns `[]` with exit code 0, same as a healthy file. Worth a warning?
##########
airflow-core/src/airflow/cli/commands/dag_command.py:
##########
@@ -672,9 +673,26 @@ def dag_details(args, *, session: Session = NEW_SESSION):
@provide_session
def dag_list_import_errors(args, *, session: Session = NEW_SESSION) -> None:
"""Display dags with import errors on the command line."""
- data = []
+ data: list[dict[str, str]] = []
- if args.local:
+ if args.dag_path:
+ if args.bundle_name:
+ raise SystemExit("--dag-path cannot be used with --bundle-name")
+
+ path = Path(args.dag_path).resolve()
+ if path.is_file():
+ bundle_path = path.parent
+ elif path.is_dir():
+ bundle_path = path
+ else:
+ raise SystemExit(f"Dag path {path} does not exist or is not a file
or directory.")
+
+ path_dagbag = BundleDagBag(path, bundle_path=bundle_path)
+ data.extend(
Review Comment:
nit: `filepath` is absolute here but relative in `--local --bundle-name`,
and there is no `bundle_name`. Could the branches share one row shape?
--
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]