SameerMesiah97 commented on code in PR #72163:
URL: https://github.com/apache/airflow/pull/72163#discussion_r3874806366
##########
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##########
@@ -1199,6 +1199,22 @@ def merge_commands(
ARG_MAP_INDEX,
),
),
+ ActionCommand(
+ name="state",
+ help="Get the state of a task instance",
+ description=(
+ "Get the state of a task instance. "
+ "Select the run with either run_id or --logical-date (pass exactly
one)."
Review Comment:
When `--logical-date` is provided, this resolves the run ID through a lookup
using `order_by="-id"` and `limit=1`. Should the help text explain that the
latest matching Dag run is selected? Alternatively, if multiple matches should
not be possible, are the ordering and limit necessary?
##########
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##########
@@ -126,6 +126,37 @@ def failed_deps(args, api_client=NEW_API_CLIENT) -> None:
)
+@provide_api_client(kind=ClientKind.CLI)
+def state(args, api_client=NEW_API_CLIENT) -> None:
+ """Get the state of a task instance."""
+ if (args.run_id is None) == (args.logical_date is None):
+ rich.print("[red]Provide either run_id or --logical-date, but not
both[/red]")
+ sys.exit(1)
+
+ run_id = args.run_id or _find_run_id_by_logical_date(api_client,
args.dag_id, args.logical_date)
Review Comment:
This is hard to understand. You can make it more explicit. Please see the
below:
```
if args.run_id is not None and args.logical_date is not None:
rich.print("[red]Provide either run_id or --logical-date, but not
both[/red]")
sys.exit(1)
if args.run_id is not None:
run_id = args.run_id
else:
run_id = _find_run_id_by_logical_date(api_client, args.dag_id,
args.logical_date)
```
--
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]