Re: [PR] airflowctl add tasks clear command [airflow]

2026-06-18 Thread via GitHub


potiuk commented on PR #66179:
URL: https://github.com/apache/airflow/pull/66179#issuecomment-4746444289

   Closing as a stale triaged draft — no update in ~9 days since the triage 
note. No worries: reopen this or open a fresh PR whenever you're ready to 
continue. Thanks for the contribution!


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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-06-18 Thread via GitHub


potiuk closed pull request #66179: airflowctl add tasks clear command
URL: https://github.com/apache/airflow/pull/66179


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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-06-09 Thread via GitHub


potiuk commented on PR #66179:
URL: https://github.com/apache/airflow/pull/66179#issuecomment-4657818463

   @raushanprabhakar1 Converting to **draft** — this PR does not yet meet our 
[Pull Request quality 
criteria](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-quality-criteria).
   
   - :x: **Merge conflicts** with `main`. See 
[docs](https://github.com/apache/airflow/blob/main/contributing-docs/10_working_with_git.rst).
   
   See the linked criteria for how to fix each item, then mark the PR "Ready 
for review". This is **not** a rejection — just an invitation to bring the PR 
up to standard. No rush.
   
   _Note: This comment was drafted by an AI-assisted triage tool and may 
contain mistakes. Once you have addressed the points above, an Apache Airflow 
maintainer — a real person — will take the next look at your PR. We use this 
[two-stage triage 
process](https://github.com/apache/airflow/blob/main/contributing-docs/25_maintainer_pr_triage.md#why-the-first-pass-is-automated)
 so that our maintainers' limited time is spent where it matters most: the 
conversation with you._


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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-24 Thread via GitHub


potiuk commented on PR #66179:
URL: https://github.com/apache/airflow/pull/66179#issuecomment-4529556840

   @raushanprabhakar1 A few things need addressing before review — see our 
[Pull Request quality 
criteria](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-quality-criteria).
   
   - :x: **CI fails**: `Additional PROD image tests / Airflow CTL integration 
tests with PROD image` (and possibly other checks — see the [Checks 
tab](https://github.com/apache/airflow/pull/66179/checks) for the full list).
   
   No rush.
   
   ---
   
   _Note: This comment was drafted by an AI-assisted triage tool and may 
contain mistakes. Once you have addressed the points above, an Apache Airflow 
maintainer — a real person — will take the next look at your PR. We use this 
[two-stage triage 
process](https://github.com/apache/airflow/blob/main/contributing-docs/25_maintainer_pr_triage.md#why-the-first-pass-is-automated)
 so that our maintainers' limited time is spent where it matters most: the 
conversation with you._
   
   ---
   Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting
   


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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-19 Thread via GitHub


bugraoz93 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3269928563


##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -595,13 +614,66 @@ def _create_arg_for_non_primitive_type(
 self._create_arg(
 arg_flags=("--" + 
self._sanitize_arg_parameter_key(field),),
 arg_type=self._python_type_from_string(annotation),
-arg_action=argparse.BooleanOptionalAction if 
annotation is bool else None,  # type: ignore
+arg_action=argparse.BooleanOptionalAction if 
annotation is bool else None,  # type: ignore[misc]
 arg_help=f"{field} for {parameter_key} operation",
 arg_default=False if annotation is bool else None,
 )
 )
 return commands
 
+def _cli_args_clear_task_instances_body(self, parameter_key: str) -> 
list[Arg]:

Review Comment:
   I still didn't quite follow why all these needed in cli config



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-18 Thread via GitHub


raushanprabhakar1 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3253241961


##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -571,35 +599,62 @@ def _create_arg_for_non_primitive_type(
 commands = []
 if parameter_type_map not in self.datamodels_extended_map.keys():
 self.datamodels_extended_map[parameter_type] = []
-for field, field_type in parameter_type_map.model_fields.items():
+for field, field_info in parameter_type_map.model_fields.items():
 if field in self.excluded_parameters:
 continue
 self.datamodels_extended_map[parameter_type].append(field)
-if type(field_type.annotation) is type:
+leaf_ann = self._leaf_annotation(field_info.annotation)
+pydantic_default = None if field_info.default is PydanticUndefined 
else field_info.default
+
+if parameter_type == "ClearTaskInstancesBody" and field == 
"task_ids":
 commands.append(
 self._create_arg(
 arg_flags=("--" + 
self._sanitize_arg_parameter_key(field),),
-
arg_type=self._python_type_from_string(field_type.annotation),
-arg_action=argparse.BooleanOptionalAction if 
field_type.annotation is bool else None,  # type: ignore
+arg_type=string_list_type,
+arg_action=None,
 arg_help=f"{field} for {parameter_key} operation",
-arg_default=False if field_type.annotation is bool 
else None,
+arg_default=pydantic_default,
 )
 )
-else:
-try:
-annotation = field_type.annotation.__args__[0]
-except AttributeError:
-annotation = field_type.annotation
+continue
 
+if leaf_ann is bool:
+cli_bool_default = pydantic_default
+if parameter_type == "ClearTaskInstancesBody" and field == 
"dry_run":
+cli_bool_default = False
 commands.append(
 self._create_arg(
 arg_flags=("--" + 
self._sanitize_arg_parameter_key(field),),
-arg_type=self._python_type_from_string(annotation),
-arg_action=argparse.BooleanOptionalAction if 
annotation is bool else None,  # type: ignore
+arg_type=bool,
+arg_action=argparse.BooleanOptionalAction,
 arg_help=f"{field} for {parameter_key} operation",
-arg_default=False if annotation is bool else None,
+arg_default=cli_bool_default,
 )
 )
+continue
+
+origin = get_origin(leaf_ann)
+if leaf_ann is list or origin is list:

Review Comment:
   Hi @bugraoz93 , Reverting the global CommandFactory changes.



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-16 Thread via GitHub


raushanprabhakar1 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3253241961


##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -571,35 +599,62 @@ def _create_arg_for_non_primitive_type(
 commands = []
 if parameter_type_map not in self.datamodels_extended_map.keys():
 self.datamodels_extended_map[parameter_type] = []
-for field, field_type in parameter_type_map.model_fields.items():
+for field, field_info in parameter_type_map.model_fields.items():
 if field in self.excluded_parameters:
 continue
 self.datamodels_extended_map[parameter_type].append(field)
-if type(field_type.annotation) is type:
+leaf_ann = self._leaf_annotation(field_info.annotation)
+pydantic_default = None if field_info.default is PydanticUndefined 
else field_info.default
+
+if parameter_type == "ClearTaskInstancesBody" and field == 
"task_ids":
 commands.append(
 self._create_arg(
 arg_flags=("--" + 
self._sanitize_arg_parameter_key(field),),
-
arg_type=self._python_type_from_string(field_type.annotation),
-arg_action=argparse.BooleanOptionalAction if 
field_type.annotation is bool else None,  # type: ignore
+arg_type=string_list_type,
+arg_action=None,
 arg_help=f"{field} for {parameter_key} operation",
-arg_default=False if field_type.annotation is bool 
else None,
+arg_default=pydantic_default,
 )
 )
-else:
-try:
-annotation = field_type.annotation.__args__[0]
-except AttributeError:
-annotation = field_type.annotation
+continue
 
+if leaf_ann is bool:
+cli_bool_default = pydantic_default
+if parameter_type == "ClearTaskInstancesBody" and field == 
"dry_run":
+cli_bool_default = False
 commands.append(
 self._create_arg(
 arg_flags=("--" + 
self._sanitize_arg_parameter_key(field),),
-arg_type=self._python_type_from_string(annotation),
-arg_action=argparse.BooleanOptionalAction if 
annotation is bool else None,  # type: ignore
+arg_type=bool,
+arg_action=argparse.BooleanOptionalAction,
 arg_help=f"{field} for {parameter_key} operation",
-arg_default=False if annotation is bool else None,
+arg_default=cli_bool_default,
 )
 )
+continue
+
+origin = get_origin(leaf_ann)
+if leaf_ann is list or origin is list:

Review Comment:
   Hi @bugraoz93 , Reverting the global CommandFactory changes. Only 
ClearTaskInstancesBody (Tasks clear) is special-cased; all other nested bodies 
still use the same expansion as main. Also added clear to output_command_list 
for --output.



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-14 Thread via GitHub


bugraoz93 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3243999812


##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -571,35 +599,62 @@ def _create_arg_for_non_primitive_type(
 commands = []
 if parameter_type_map not in self.datamodels_extended_map.keys():
 self.datamodels_extended_map[parameter_type] = []
-for field, field_type in parameter_type_map.model_fields.items():
+for field, field_info in parameter_type_map.model_fields.items():
 if field in self.excluded_parameters:
 continue
 self.datamodels_extended_map[parameter_type].append(field)
-if type(field_type.annotation) is type:
+leaf_ann = self._leaf_annotation(field_info.annotation)
+pydantic_default = None if field_info.default is PydanticUndefined 
else field_info.default
+
+if parameter_type == "ClearTaskInstancesBody" and field == 
"task_ids":
 commands.append(
 self._create_arg(
 arg_flags=("--" + 
self._sanitize_arg_parameter_key(field),),
-
arg_type=self._python_type_from_string(field_type.annotation),
-arg_action=argparse.BooleanOptionalAction if 
field_type.annotation is bool else None,  # type: ignore
+arg_type=string_list_type,
+arg_action=None,
 arg_help=f"{field} for {parameter_key} operation",
-arg_default=False if field_type.annotation is bool 
else None,
+arg_default=pydantic_default,
 )
 )
-else:
-try:
-annotation = field_type.annotation.__args__[0]
-except AttributeError:
-annotation = field_type.annotation
+continue
 
+if leaf_ann is bool:
+cli_bool_default = pydantic_default
+if parameter_type == "ClearTaskInstancesBody" and field == 
"dry_run":
+cli_bool_default = False
 commands.append(
 self._create_arg(
 arg_flags=("--" + 
self._sanitize_arg_parameter_key(field),),
-arg_type=self._python_type_from_string(annotation),
-arg_action=argparse.BooleanOptionalAction if 
annotation is bool else None,  # type: ignore
+arg_type=bool,
+arg_action=argparse.BooleanOptionalAction,
 arg_help=f"{field} for {parameter_key} operation",
-arg_default=False if annotation is bool else None,
+arg_default=cli_bool_default,
 )
 )
+continue
+
+origin = get_origin(leaf_ann)
+if leaf_ann is list or origin is list:

Review Comment:
   I couldn't follow why we need these changes. The PR should only add Tasks 
commands



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-10 Thread via GitHub


potiuk commented on PR #66179:
URL: https://github.com/apache/airflow/pull/66179#issuecomment-4417449226

   @raushanprabhakar1 Converting to **draft** — this PR doesn't yet meet our 
[Pull Request quality 
criteria](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-quality-criteria).
   
   - :x: **Pre-commit / static checks** — Failing: `CI image checks / Static 
checks`. See 
[docs](https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst).
   - :x: **Unresolved review comments** — 6 unresolved review threads from 
@bugraoz93. See 
[docs](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-quality-criteria).
   
   See the linked criteria for how to fix each item, then mark the PR "Ready 
for review". This is **not** a rejection — just an invitation to bring the PR 
up to standard. No rush.
   
   ---
   
   _Note: This comment was drafted by an AI-assisted triage tool and may 
contain mistakes. Once you have addressed the points above, an Apache Airflow 
maintainer — a real person — will take the next look at your PR. We use this 
[two-stage triage 
process](https://github.com/apache/airflow/blob/main/contributing-docs/25_maintainer_pr_triage.md#why-the-first-pass-is-automated)
 so that our maintainers' limited time is spent where it matters most: the 
conversation with you._
   
   ---
   Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting
   


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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-02 Thread via GitHub


parkhojeong commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3176408551


##
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##
@@ -0,0 +1,51 @@
+# 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.
+
+from __future__ import annotations
+
+import sys
+
+import rich
+
+from airflowctl.api.client import NEW_API_CLIENT, ClientKind, 
ServerResponseError, provide_api_client
+from airflowctl.api.datamodels.generated import ClearTaskInstancesBody
+from airflowctl.ctl.console_formatting import AirflowConsole
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def clear(args, api_client=NEW_API_CLIENT) -> None:
+"""Clear task instances for a DAG run (``POST .../clearTaskInstances``, 
body includes ``dag_run_id``)."""

Review Comment:
   ```suggestion
   """Clear task instances for a Dag run (``POST .../clearTaskInstances``, 
body includes ``dag_run_id``)."""
   ```



##
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##
@@ -0,0 +1,51 @@
+# 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.
+
+from __future__ import annotations
+
+import sys
+
+import rich
+
+from airflowctl.api.client import NEW_API_CLIENT, ClientKind, 
ServerResponseError, provide_api_client
+from airflowctl.api.datamodels.generated import ClearTaskInstancesBody
+from airflowctl.ctl.console_formatting import AirflowConsole
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def clear(args, api_client=NEW_API_CLIENT) -> None:
+"""Clear task instances for a DAG run (``POST .../clearTaskInstances``, 
body includes ``dag_run_id``)."""
+body = ClearTaskInstancesBody(
+dag_run_id=args.dag_run_id,
+dry_run=args.dry_run,
+only_failed=args.only_failed,
+only_running=args.only_running,
+include_upstream=args.upstream,
+include_downstream=args.downstream,
+task_ids=args.task_ids,
+)
+
+try:
+cleared = api_client.dags.clear_task_instances(dag_id=args.dag_id, 
clear_body=body)
+except ServerResponseError as e:
+rich.print(f"[red]Error clearing tasks for DAG {args.dag_id}, run 
{args.dag_run_id}: {e}[/red]")

Review Comment:
   ```suggestion
   rich.print(f"[red]Error clearing tasks for Dag {args.dag_id}, run 
{args.dag_run_id}: {e}[/red]")
   ```



##
airflow-ctl/RELEASE_NOTES.rst:
##
@@ -45,6 +45,7 @@ Bug Fixes
 Improvements
 
 
+- Add ``airflowctl tasks clear`` for clearing task instances in a DAG run 
using the REST API (AIP-94, `#66176 
`__)

Review Comment:
   ```suggestion
   - Add ``airflowctl tasks clear`` for clearing task instances in a Dag run 
using the REST API (AIP-94, `#66176 
`__)
   ```



##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -926,6 +982,25 @@ def merge_commands(
 ),
 )
 
+TASK_COMMANDS = (
+ActionCommand(
+name="clear",
+help="Clear task instances in a DAG run",

Review Comment:
   ```suggestion
   help="Clear task instances in a Dag run",
   ```



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-01 Thread via GitHub


bugraoz93 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3174546524


##
airflow-ctl/src/airflowctl/api/operations.py:
##
@@ -592,6 +594,19 @@ def trigger(
 except ServerResponseError as e:
 raise e
 
+def clear_task_instances(

Review Comment:
   These makes everything under dags command, we need to create TasksOperations 
similar to this class. Additionally this should create a image with static 
checks.



##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -268,6 +268,60 @@ def _load_help_texts_yaml() -> dict[str, dict[str, str]]:
 help="The DAG ID of the DAG to pause or unpause",
 )
 
+ARG_TASK_CLEAR_DAG_ID = Arg(

Review Comment:
   We dont need to create these if it is in operations.py as it is created 
automatically 



##
airflow-ctl/tests/airflow_ctl/ctl/commands/test_task_command.py:
##
@@ -0,0 +1,134 @@
+# 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.
+from __future__ import annotations

Review Comment:
   Tests should only be exists in tests_operations as it should only be in api/ 
side



##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -403,6 +457,8 @@ def __init__(self, file_path: str | Path | None = None):
 "_check_flag_and_exit_if_server_response_error",
 # Excluding bulk operation. Out of scope for CLI. Should use 
implemented commands.
 "bulk",
+# Hand-written `tasks clear`; nested ClearTaskInstancesBody is not 
representable by CommandFactory.
+"clear_task_instances",

Review Comment:
   This doesn't needed as it will be auto generated



##
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##
@@ -0,0 +1,51 @@
+# 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.
+
+from __future__ import annotations
+
+import sys
+
+import rich
+
+from airflowctl.api.client import NEW_API_CLIENT, ClientKind, 
ServerResponseError, provide_api_client
+from airflowctl.api.datamodels.generated import ClearTaskInstancesBody
+from airflowctl.ctl.console_formatting import AirflowConsole
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def clear(args, api_client=NEW_API_CLIENT) -> None:

Review Comment:
   Wince you created the method in the operations this also doesn't needed 
similar to above comment as cli_config. The factory in cli config will generate 
methods commands 



##
airflow-ctl/RELEASE_NOTES.rst:
##
@@ -45,6 +45,7 @@ Bug Fixes
 Improvements
 
 
+- Add ``airflowctl tasks clear`` for clearing task instances in a DAG run 
using the REST API (AIP-94, `#66176 
`__)

Review Comment:
   We are populating this when releasing. Could you please remove it?



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-01 Thread via GitHub


raushanprabhakar1 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3174199514


##
airflow-ctl/tests/airflow_ctl/ctl/commands/test_task_command.py:
##
@@ -0,0 +1,137 @@
+# 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.
+from __future__ import annotations
+
+import json
+
+import httpx
+import pytest
+
+from airflowctl.api.client import Client, ClientKind
+from airflowctl.ctl import cli_parser
+from airflowctl.ctl.commands import task_command
+
+
+class TestTaskCommands:
+parser = cli_parser.get_parser()
+dag_id = "test_dag"
+dag_run_id = "test_run"
+
+def test_tasks_clear(self):

Review Comment:
   HI @henry3260 , incorporated your suggestion, Thanks.



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-01 Thread via GitHub


henry3260 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3173464193


##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -268,6 +268,60 @@ def _load_help_texts_yaml() -> dict[str, dict[str, str]]:
 help="The DAG ID of the DAG to pause or unpause",
 )
 
+ARG_TASK_CLEAR_DAG_ID = Arg(
+flags=("--dag-id",),
+type=str,
+required=True,
+dest="dag_id",
+help="DAG ID whose task instances are cleared",
+)
+ARG_TASK_DAG_RUN_ID = Arg(
+flags=("--dag-run-id",),
+type=str,
+required=True,
+dest="dag_run_id",
+help="DAG run ID that scopes which task instances are cleared",

Review Comment:
   ```suggestion
   help="Dag run ID that scopes which task instances are cleared",
   ```



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-01 Thread via GitHub


henry3260 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3173463445


##
airflow-ctl/src/airflowctl/ctl/cli_config.py:
##
@@ -268,6 +268,60 @@ def _load_help_texts_yaml() -> dict[str, dict[str, str]]:
 help="The DAG ID of the DAG to pause or unpause",
 )
 
+ARG_TASK_CLEAR_DAG_ID = Arg(
+flags=("--dag-id",),
+type=str,
+required=True,
+dest="dag_id",
+help="DAG ID whose task instances are cleared",

Review Comment:
   ```suggestion
   help="Dag ID whose task instances are cleared",
   ```



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-01 Thread via GitHub


raushanprabhakar1 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3173279128


##
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##
@@ -0,0 +1,60 @@
+# 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.
+
+from __future__ import annotations
+
+import sys
+
+import rich
+
+from airflowctl.api.client import NEW_API_CLIENT, ClientKind, 
ServerResponseError, provide_api_client
+from airflowctl.api.datamodels.generated import ClearTaskInstancesBody, 
TaskInstanceCollectionResponse
+from airflowctl.ctl.console_formatting import AirflowConsole
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def clear(args, api_client=NEW_API_CLIENT) -> None:
+"""
+Clear task instances for a DAG run via POST 
``/api/v2/dags/{dag_id}/clearTaskInstances``.
+
+The DAG run is selected with ``dag_run_id`` in the JSON body (not the URL 
path).
+"""
+body = ClearTaskInstancesBody(
+dag_run_id=args.dag_run_id,
+dry_run=args.dry_run,
+only_failed=args.only_failed,
+only_running=args.only_running,
+include_upstream=args.upstream,
+include_downstream=args.downstream,
+task_ids=args.task_ids,
+)
+
+path = f"dags/{args.dag_id}/clearTaskInstances"
+try:
+response = api_client.post(path, json=body.model_dump(mode="json", 
exclude_none=True))
+cleared = 
TaskInstanceCollectionResponse.model_validate_json(response.content)
+except ServerResponseError as e:
+rich.print(f"[red]Error clearing tasks for DAG {args.dag_id}, run 
{args.dag_run_id}: {e}[/red]")
+sys.exit(1)
+
+payload = cleared.model_dump(mode="json")
+cleared_task_instances = payload.get("task_instances", [])

Review Comment:
   Hi @henry3260 , I have moved the suggested logic changes in `operations.py`, 
Please do review. Thanks



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-01 Thread via GitHub


raushanprabhakar1 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3173269860


##
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##
@@ -0,0 +1,60 @@
+# 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.
+
+from __future__ import annotations
+
+import sys
+
+import rich
+
+from airflowctl.api.client import NEW_API_CLIENT, ClientKind, 
ServerResponseError, provide_api_client
+from airflowctl.api.datamodels.generated import ClearTaskInstancesBody, 
TaskInstanceCollectionResponse
+from airflowctl.ctl.console_formatting import AirflowConsole
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def clear(args, api_client=NEW_API_CLIENT) -> None:
+"""
+Clear task instances for a DAG run via POST 
``/api/v2/dags/{dag_id}/clearTaskInstances``.
+
+The DAG run is selected with ``dag_run_id`` in the JSON body (not the URL 
path).
+"""
+body = ClearTaskInstancesBody(
+dag_run_id=args.dag_run_id,
+dry_run=args.dry_run,
+only_failed=args.only_failed,
+only_running=args.only_running,
+include_upstream=args.upstream,
+include_downstream=args.downstream,
+task_ids=args.task_ids,
+)
+
+path = f"dags/{args.dag_id}/clearTaskInstances"
+try:
+response = api_client.post(path, json=body.model_dump(mode="json", 
exclude_none=True))
+cleared = 
TaskInstanceCollectionResponse.model_validate_json(response.content)
+except ServerResponseError as e:
+rich.print(f"[red]Error clearing tasks for DAG {args.dag_id}, run 
{args.dag_run_id}: {e}[/red]")
+sys.exit(1)
+
+payload = cleared.model_dump(mode="json")
+cleared_task_instances = payload.get("task_instances", [])

Review Comment:
   Hi @henry3260 , i have addressed your feedbacks, please do review, Thanks



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



Re: [PR] airflowctl add tasks clear command [airflow]

2026-05-01 Thread via GitHub


henry3260 commented on code in PR #66179:
URL: https://github.com/apache/airflow/pull/66179#discussion_r3172756831


##
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##
@@ -0,0 +1,60 @@
+# 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.
+
+from __future__ import annotations
+
+import sys
+
+import rich
+
+from airflowctl.api.client import NEW_API_CLIENT, ClientKind, 
ServerResponseError, provide_api_client
+from airflowctl.api.datamodels.generated import ClearTaskInstancesBody, 
TaskInstanceCollectionResponse
+from airflowctl.ctl.console_formatting import AirflowConsole
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def clear(args, api_client=NEW_API_CLIENT) -> None:
+"""
+Clear task instances for a DAG run via POST 
``/api/v2/dags/{dag_id}/clearTaskInstances``.
+
+The DAG run is selected with ``dag_run_id`` in the JSON body (not the URL 
path).
+"""
+body = ClearTaskInstancesBody(
+dag_run_id=args.dag_run_id,
+dry_run=args.dry_run,
+only_failed=args.only_failed,
+only_running=args.only_running,
+include_upstream=args.upstream,
+include_downstream=args.downstream,
+task_ids=args.task_ids,
+)
+
+path = f"dags/{args.dag_id}/clearTaskInstances"
+try:
+response = api_client.post(path, json=body.model_dump(mode="json", 
exclude_none=True))
+cleared = 
TaskInstanceCollectionResponse.model_validate_json(response.content)
+except ServerResponseError as e:
+rich.print(f"[red]Error clearing tasks for DAG {args.dag_id}, run 
{args.dag_run_id}: {e}[/red]")
+sys.exit(1)
+
+payload = cleared.model_dump(mode="json")
+cleared_task_instances = payload.get("task_instances", [])

Review Comment:
   I wonder if it would be better to move this logic into `operations.py`, and 
keep the command focused on composing the request and formatting the output.



##
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##
@@ -0,0 +1,60 @@
+# 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.
+
+from __future__ import annotations
+
+import sys
+
+import rich
+
+from airflowctl.api.client import NEW_API_CLIENT, ClientKind, 
ServerResponseError, provide_api_client
+from airflowctl.api.datamodels.generated import ClearTaskInstancesBody, 
TaskInstanceCollectionResponse
+from airflowctl.ctl.console_formatting import AirflowConsole
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def clear(args, api_client=NEW_API_CLIENT) -> None:
+"""
+Clear task instances for a DAG run via POST 
``/api/v2/dags/{dag_id}/clearTaskInstances``.
+
+The DAG run is selected with ``dag_run_id`` in the JSON body (not the URL 
path).
+"""
+body = ClearTaskInstancesBody(
+dag_run_id=args.dag_run_id,
+dry_run=args.dry_run,
+only_failed=args.only_failed,
+only_running=args.only_running,
+include_upstream=args.upstream,
+include_downstream=args.downstream,
+task_ids=args.task_ids,
+)
+
+path = f"dags/{args.dag_id}/clearTaskInstances"
+try:
+response = api_client.post(path, json=body.model_dump(mode="json", 
exclude_none=True))
+cleared = 
TaskInstanceCollectionResponse.model_validate_json(response.content)
+except ServerResponseError as e:
+rich.print(f"[red]Error clearing tasks for DAG {args.dag_id}, run 
{args.dag_run_id}: {e}[/red]")
+sys.exit(1)
+
+payload = cleared.model_dump(mode="json")
+clea