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


##########
scripts/ci/prek/check_airflowctl_command_coverage.py:
##########
@@ -0,0 +1,160 @@
+#!/usr/bin/env python
+#
+# 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.
+# /// script
+# requires-python = ">=3.10,<3.11"
+# dependencies = [
+#   "rich>=13.6.0",
+# ]
+# ///
+"""
+Check that all airflowctl CLI commands have integration test coverage by 
comparing  commands from operations.py against test_commands in conftest.py.
+"""
+
+from __future__ import annotations
+
+import ast
+import re
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).parent.resolve()))
+from common_prek_utils import AIRFLOW_ROOT_PATH, console
+
+OPERATIONS_FILE = AIRFLOW_ROOT_PATH / "airflow-ctl" / "src" / "airflowctl" / 
"api" / "operations.py"
+CONFTEST_FILE = AIRFLOW_ROOT_PATH / "airflow-ctl-tests" / "tests" / 
"airflowctl_tests" / "conftest.py"
+
+# Operations excluded from CLI (see cli_config.py)
+EXCLUDED_OPERATION_CLASSES = {"BaseOperations", "LoginOperations", 
"VersionOperations"}
+EXCLUDED_METHODS = {
+    "__init__",
+    "__init_subclass__",
+    "error",
+    "_check_flag_and_exit_if_server_response_error",
+    "bulk",
+}
+
+# Commands intentionally not tested - grouped by reason:
+EXCLUDED_COMMANDS = {
+    # Assets - require asset state/dependencies
+    "assets materialize",
+    "assets get",

Review Comment:
   We should be able to add these because default assets are already included 
in the deployment. For example, we have `assets list` already returning this, I 
believe with the correct params, we should be able to include
   
   ```
   [{"id": "1", "name": "s3://bucket/my-task", "uri": "s3://bucket/my-task", 
"group": "asset", "extra": {}, "created_at": "2025-11-30T00:26:35.936723Z", 
"updated_at": "2025-11-30T00:26:35.936735Z", "scheduled_dags": [{"dag_id": 
"asset_s3_bucket_consumer", "created_at": "2025-11-30T00:26:35.943756Z", 
"updated_at": "2025-11-30T00:26:35.943766Z"}], "producing_tasks": [{"dag_id": 
     "asset_s3_bucket_producer", "task_id": "produce_asset_events", 
"created_at": "2025-11-30T00:26:35.951756Z", "updated_at": 
"2025-11-30T00:26:35.951765Z"}], "consuming_tasks": [], "aliases": [], 
"watchers": [], "last_asset_event": {"id": null, "timestamp": null}}, {"id": 
"2", "name": "s3://bucket/my-task-with-no-taskflow", "uri": 
"s3://bucket/my-task-with-no-taskflow", "group": "asset", "extra": {},
     "created_at": "2025-11-30T00:26:39.226203Z", "updated_at": 
"2025-11-30T00:26:39.226213Z", "scheduled_dags": [{"dag_id": 
"asset_s3_bucket_consumer_with_no_taskflow", "created_at": 
"2025-11-30T00:26:39.231365Z", "updated_at": "2025-11-30T00:26:39.231373Z"}], 
"producing_tasks": [{"dag_id": "asset_s3_bucket_producer_with_no_taskflow", 
"task_id": "produce_asset_events", "created_at": 
     "2025-11-30T00:26:39.235546Z", "updated_at": 
"2025-11-30T00:26:39.235555Z"}], "consuming_tasks": [], "aliases": [], 
"watchers": [], "last_asset_event": {"id": null, "timestamp": null}}, {"id": 
"3", "name": "example_asset", "uri": "example_asset", "group": "asset", 
"extra": {}, "created_at": "2025-11-30T00:26:39.607360Z", "updated_at": 
"2025-11-30T00:26:39.607368Z", "scheduled_dags": [{
     "example_asset_with_watchers", "created_at": 
"2025-11-30T00:26:39.611273Z", "updated_at": "2025-11-30T00:26:39.611281Z"}], 
"producing_tasks": [], "consuming_tasks": [], "aliases": [], "watchers": [], 
"last_asset_event": {"id": null, "timestamp": null}}, {"id": "4", "name": 
"test-asset", "uri": "s3://output/1.txt", "group": "asset", "extra": {}, 
"created_at": "2025-11-30T00:26:41.914676Z"
     "updated_at": "2025-11-30T00:26:41.914686Z", "scheduled_dags": [], 
"producing_tasks": [{"dag_id": "asset_with_extra_by_yield", "task_id": 
"asset_with_extra_by_yield", "created_at": "2025-11-30T00:26:41.923433Z", 
"updated_at": "2025-11-30T00:26:41.923442Z"}, {"dag_id": 
"asset_with_extra_by_context", "task_id": "asset_with_extra_by_context", 
"created_at": "2025-11-30T00:26:41.924003Z", "updated_at":
     "2025-11-30T00:26:41.924010Z"}, {"dag_id": 
"asset_with_extra_from_classic_operator", "task_id": 
"asset_with_extra_from_classic_operator", "created_at": 
"2025-11-30T00:26:41.924523Z", "updated_at": "2025-11-30T00:26:41.924531Z"}], 
"consuming_tasks": [], "aliases": [], "watchers": [], "last_asset_event": 
{"id": null, "timestamp": null}}, {"id": "5", "name": "asset1_producer", "uri": 
     "s3://bucket/asset1_producer", "group": "asset", "extra": {}, 
"created_at": "2025-11-30T00:26:42.519160Z", "updated_at": 
"2025-11-30T00:26:42.519168Z", "scheduled_dags": [{"dag_id": 
"consumes_asset_decorator", "created_at": "2025-11-30T00:26:42.525573Z", 
"updated_at": "2025-11-30T00:26:42.525579Z"}], "producing_tasks": [{"dag_id": 
"asset1_producer", "task_id": "asset1_producer", "created_at": 
     "2025-11-30T00:26:42.528604Z", "updated_at": 
"2025-11-30T00:26:42.528613Z"}], "consuming_tasks": [], "aliases": [], 
"watchers": [], "last_asset_event": {"id": null, "timestamp": null}}, {"id": 
"6", "name": "asset2_producer", "uri": "s3://bucket/object", "group": "asset", 
"extra": {}, "created_at": "2025-11-30T00:26:42.519173Z", "updated_at": 
"2025-11-30T00:26:42.519177Z", "scheduled_dags": 
     [{"dag_id": "consumes_asset_decorator", "created_at": 
"2025-11-30T00:26:42.525583Z", "updated_at": "2025-11-30T00:26:42.525587Z"}], 
"producing_tasks": [{"dag_id": "asset2_producer", "task_id": "asset2_producer", 
"created_at": "2025-11-30T00:26:42.529152Z", "updated_at": 
"2025-11-30T00:26:42.529159Z"}], "consuming_tasks": [], "aliases": [], 
"watchers": [], "last_asset_event": {"id": null, 
     "timestamp": null}}, {"id": "7", "name": "process_nothing", "uri": 
"process_nothing", "group": "asset", "extra": {}, "created_at": 
"2025-11-30T00:26:42.519180Z", "updated_at": "2025-11-30T00:26:42.519184Z", 
"scheduled_dags": [], "producing_tasks": [{"dag_id": 
"consumes_asset_decorator", "task_id": "process_nothing", "created_at": 
"2025-11-30T00:26:42.529570Z", "updated_at": 
     "2025-11-30T00:26:42.529577Z"}], "consuming_tasks": [], "aliases": [], 
"watchers": [], "last_asset_event": {"id": null, "timestamp": null}}, {"id": 
"9", "name": "s3://dag1/output_1.txt", "uri": "s3://dag1/output_1.txt", 
"group": "asset", "extra": {"hi": "bye"}, "created_at": 
"2025-11-30T00:26:43.968661Z", "updated_at": "2025-11-30T00:26:43.968669Z", 
"scheduled_dags": [{"dag_id": 
     "consume_1_or_both_2_and_3_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.977966Z", "updated_at": "2025-11-30T00:26:43.977973Z"}, 
{"dag_id": "asset_consumes_1_never_scheduled", "created_at": 
"2025-11-30T00:26:43.978750Z", "updated_at": "2025-11-30T00:26:43.978757Z"}, 
{"dag_id": "asset_consumes_1_and_2", "created_at": 
"2025-11-30T00:26:43.979369Z", "updated_at": 
     "2025-11-30T00:26:43.979376Z"}, {"dag_id": "asset_consumes_1", 
"created_at": "2025-11-30T00:26:43.979956Z", "updated_at": 
"2025-11-30T00:26:43.979964Z"}, {"dag_id": 
"consume_1_or_2_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.980431Z", "updated_at": "2025-11-30T00:26:43.980438Z"}, 
{"dag_id": "conditional_asset_and_time_based_timetable", "created_at": 
"2025-11-30T00:26:43.981041Z", 
     "updated_at": "2025-11-30T00:26:43.981048Z"}, {"dag_id": 
"consume_1_and_2_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.982316Z", "updated_at": "2025-11-30T00:26:43.982323Z"}], 
"producing_tasks": [{"dag_id": "asset_produces_1", "task_id": 
"producing_task_1", "created_at": "2025-11-30T00:26:43.993027Z", "updated_at": 
"2025-11-30T00:26:43.993034Z"}], "consuming_tasks": [], "aliases": 
     [], "watchers": [], "last_asset_event": {"id": null, "timestamp": null}}, 
{"id": "10", "name": "s3://dag2/output_1.txt", "uri": "s3://dag2/output_1.txt", 
"group": "asset", "extra": {"hi": "bye"}, "created_at": 
"2025-11-30T00:26:43.968672Z", "updated_at": "2025-11-30T00:26:43.968674Z", 
"scheduled_dags": [{"dag_id": 
"consume_1_or_both_2_and_3_with_asset_expressions", "created_at": 
     "2025-11-30T00:26:43.977978Z", "updated_at": 
"2025-11-30T00:26:43.977981Z"}, {"dag_id": "asset_consumes_1_and_2", 
"created_at": "2025-11-30T00:26:43.979380Z", "updated_at": 
"2025-11-30T00:26:43.979384Z"}, {"dag_id": 
"consume_1_or_2_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.980443Z", "updated_at": "2025-11-30T00:26:43.980446Z"}, 
{"dag_id": 
     "conditional_asset_and_time_based_timetable", "created_at": 
"2025-11-30T00:26:43.981053Z", "updated_at": "2025-11-30T00:26:43.981056Z"}, 
{"dag_id": "consume_1_and_2_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.982328Z", "updated_at": "2025-11-30T00:26:43.982331Z"}], 
"producing_tasks": [{"dag_id": "asset_produces_2", "task_id": 
"producing_task_2", "created_at": 
     "2025-11-30T00:26:43.993472Z", "updated_at": 
"2025-11-30T00:26:43.993479Z"}], "consuming_tasks": [], "aliases": [], 
"watchers": [], "last_asset_event": {"id": null, "timestamp": null}}, {"id": 
"11", "name": "s3://dag3/output_3.txt", "uri": "s3://dag3/output_3.txt", 
"group": "asset", "extra": {"hi": "bye"}, "created_at": 
"2025-11-30T00:26:43.968676Z", "updated_at": "2025-11-30T00:26:43.968678Z", 
     "scheduled_dags": [{"dag_id": 
"consume_1_or_both_2_and_3_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.977984Z", "updated_at": "2025-11-30T00:26:43.977988Z"}], 
"producing_tasks": [], "consuming_tasks": [], "aliases": [], "watchers": [], 
"last_asset_event": {"id": null, "timestamp": null}}, {"id": "12", "name": 
"s3://consuming_2_task/asset_other_unknown.txt", "uri": 
     "s3://consuming_2_task/asset_other_unknown.txt", "group": "asset", 
"extra": {}, "created_at": "2025-11-30T00:26:43.968680Z", "updated_at": 
"2025-11-30T00:26:43.968681Z", "scheduled_dags": [], "producing_tasks": 
[{"dag_id": "consume_1_or_both_2_and_3_with_asset_expressions", "task_id": 
"consume_1_or_both_2_and_3_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.989738Z", "updated_at": 
     "2025-11-30T00:26:43.989747Z"}, {"dag_id": 
"asset_consumes_1_never_scheduled", "task_id": "consuming_3", "created_at": 
"2025-11-30T00:26:43.990251Z", "updated_at": "2025-11-30T00:26:43.990259Z"}, 
{"dag_id": "asset_consumes_1_and_2", "task_id": "consuming_2", "created_at": 
"2025-11-30T00:26:43.990721Z", "updated_at": "2025-11-30T00:26:43.990729Z"}, 
{"dag_id": 
     "consume_1_or_2_with_asset_expressions", "task_id": 
"consume_1_or_2_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.991639Z", "updated_at": "2025-11-30T00:26:43.991646Z"}, 
{"dag_id": "consume_1_and_2_with_asset_expressions", "task_id": 
"consume_1_and_2_with_asset_expressions", "created_at": 
"2025-11-30T00:26:43.993932Z", "updated_at": "2025-11-30T00:26:43.993939Z"}], 
"consuming_tasks":
     [], "aliases": [], "watchers": [], "last_asset_event": {"id": null, 
"timestamp": null}}, {"id": "13", "name": 
"s3://unrelated/this-asset-doesnt-get-triggered", "uri": 
"s3://unrelated/this-asset-doesnt-get-triggered", "group": "asset", "extra": 
{}, "created_at": "2025-11-30T00:26:43.968683Z", "updated_at": 
"2025-11-30T00:26:43.968685Z", "scheduled_dags": [{"dag_id": 
     "asset_consumes_1_never_scheduled", "created_at": 
"2025-11-30T00:26:43.978762Z", "updated_at": "2025-11-30T00:26:43.978765Z"}], 
"producing_tasks": [], "consuming_tasks": [], "aliases": [], "watchers": [], 
"last_asset_event": {"id": null, "timestamp": null}}, {"id": "14", "name": 
"s3://consuming_1_task/asset_other.txt", "uri": 
"s3://consuming_1_task/asset_other.txt", "group": "asset", "extra": {}, 
     "created_at": "2025-11-30T00:26:43.968687Z", "updated_at": 
"2025-11-30T00:26:43.968689Z", "scheduled_dags": [], "producing_tasks": 
[{"dag_id": "asset_consumes_1", "task_id": "consuming_1", "created_at": 
"2025-11-30T00:26:43.991190Z", "updated_at": "2025-11-30T00:26:43.991197Z"}], 
"consuming_tasks": [], "aliases": [], "watchers": [], "last_asset_event": 
{"id": null, "timestamp": null}}, {"id": 
     "15", "name": "s3://asset_time_based/asset_other_unknown.txt", "uri": 
"s3://asset_time_based/asset_other_unknown.txt", "group": "asset", "extra": {}, 
"created_at": "2025-11-30T00:26:43.968691Z", "updated_at": 
"2025-11-30T00:26:43.968693Z", "scheduled_dags": [], "producing_tasks": 
[{"dag_id": "conditional_asset_and_time_based_timetable", "task_id": 
"conditional_asset_and_time_based_timetable", 
     "created_at": "2025-11-30T00:26:43.992105Z", "updated_at": 
"2025-11-30T00:26:43.992112Z"}], "consuming_tasks": [], "aliases": [], 
"watchers": [], "last_asset_event": {"id": null, "timestamp": null}}, {"id": 
"16", "name": "s3://unrelated/asset3.txt", "uri": "s3://unrelated/asset3.txt", 
"group": "asset", "extra": {}, "created_at": "2025-11-30T00:26:43.968695Z", 
"updated_at": 
     "2025-11-30T00:26:43.968696Z", "scheduled_dags": [{"dag_id": 
"asset_consumes_unknown_never_scheduled", "created_at": 
"2025-11-30T00:26:43.981617Z", "updated_at": "2025-11-30T00:26:43.981624Z"}], 
"producing_tasks": [], "consuming_tasks": [], "aliases": [], "watchers": [], 
"last_asset_event": {"id": null, "timestamp": null}}, {"id": "17", "name": 
"s3://unrelated/asset_other_unknown.txt", "uri": 
     "s3://unrelated/asset_other_unknown.txt", "group": "asset", "extra": {}, 
"created_at": "2025-11-30T00:26:43.968698Z", "updated_at": 
"2025-11-30T00:26:43.968700Z", "scheduled_dags": [{"dag_id": 
"asset_consumes_unknown_never_scheduled", "created_at": 
"2025-11-30T00:26:43.981629Z", "updated_at": "2025-11-30T00:26:43.981633Z"}], 
"producing_tasks": [], "consuming_tasks": [], "aliases": [], "watchers": 
     [], "last_asset_event": {"id": null, "timestamp": null}}, {"id": "18", 
"name": "s3://unrelated_task/asset_other_unknown.txt", "uri": 
"s3://unrelated_task/asset_other_unknown.txt", "group": "asset", "extra": {}, 
"created_at": "2025-11-30T00:26:43.968702Z", "updated_at": 
"2025-11-30T00:26:43.968704Z", "scheduled_dags": [], "producing_tasks": 
[{"dag_id": "asset_consumes_unknown_never_scheduled", 
     "task_id": "unrelated_task", "created_at": "2025-11-30T00:26:43.992558Z", 
"updated_at": "2025-11-30T00:26:43.992565Z"}], "consuming_tasks": [], 
"aliases": [], "watchers": [], "last_asset_event": {"id": null, "timestamp": 
null}}]
   ```



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