bugraoz93 commented on code in PR #66218:
URL: https://github.com/apache/airflow/pull/66218#discussion_r3178514498
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -920,3 +920,77 @@ def list_import_errors(self) ->
PluginImportErrorCollectionResponse | ServerResp
return
PluginImportErrorCollectionResponse.model_validate_json(self.response.content)
except ServerResponseError as e:
raise e
+
+
+class TaskOperations(BaseOperations):
+ """Task instance operations."""
+
+ def states_for_dag_run(
+ self, dag_id: str, dag_run_id: str, limit: int = 100
+ ) -> TaskInstanceCollectionResponse | ServerResponseError:
+ """
+ Get task instance states for a DAG run.
+
+ Args:
+ dag_id: The DAG ID.
+ dag_run_id: The DAG run ID.
+ limit: Maximum number of task instances to return.
+ """
+ try:
+ self.response = self.client.get(
+ f"/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances",
+ params={"limit": limit},
+ )
+ return
TaskInstanceCollectionResponse.model_validate_json(self.response.content)
+ except ServerResponseError as e:
+ raise e
+
+ def clear(
+ self,
+ dag_id: str,
Review Comment:
I assume this can be pydantic datamodel rather adding all, same apply above
one if we can use it as factory will resolve them
##########
airflow-ctl/src/airflowctl/ctl/commands/task_command.py:
##########
@@ -0,0 +1,93 @@
+# 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.
+"""Task commands for airflowctl."""
+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,
+ ClearTaskInstanceCollectionResponse,
+ TaskInstanceCollectionResponse,
+)
+from airflowctl.ctl.console_formatting import AirflowConsole
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def clear(args, api_client=NEW_API_CLIENT) -> None:
Review Comment:
This is still here, I think we should delete all these and only keep
operations for clear that works with single endpoint
--
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]