dheerajturaga commented on code in PR #61946:
URL: https://github.com/apache/airflow/pull/61946#discussion_r2809809626
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -824,3 +828,54 @@ def delete(
return key
except ServerResponseError as e:
raise e
+
+
+class TaskInstanceOperations(BaseOperations):
+ """Task instance operations."""
+
+ def get(
+ self, dag_id: str, dag_run_id: str, task_id: str
+ ) -> TaskInstanceResponse | ServerResponseError:
+ """Get a task instance."""
+ try:
+ self.response = self.client.get(
+ f"dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}"
+ )
+ return
TaskInstanceResponse.model_validate_json(self.response.content)
+ except ServerResponseError as e:
+ raise e
+
+ def list(
+ self, dag_id: str, dag_run_id: str
+ ) -> TaskInstanceCollectionResponse | ServerResponseError:
+ """List task instances."""
+ return super().execute_list(
+ path=f"dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances",
+ data_model=TaskInstanceCollectionResponse,
+ )
+
+ def clear(
Review Comment:
clear seems to be a new output command. You would need to add it to the
command list here
https://github.com/apache/airflow/blob/7b33e9baf0443e11548fd5a9eb6fe395397993a7/airflow-ctl/src/airflowctl/ctl/cli_config.py#L387
Take a look at the example: #61021
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -824,3 +828,54 @@ def delete(
return key
except ServerResponseError as e:
raise e
+
+
+class TaskInstanceOperations(BaseOperations):
Review Comment:
Unit tests for api operations are captured here
https://github.com/apache/airflow/blob/7b33e9baf0443e11548fd5a9eb6fe395397993a7/airflow-ctl/tests/airflow_ctl/api/test_operations.py
Would you be able to add a comprehensive suite of tests for these
operations?
Here's a good example: #61021
##########
airflow-ctl-tests/tests/airflowctl_tests/test_airflowctl_commands.py:
##########
@@ -90,6 +90,9 @@ def date_param():
"dags update --dag-id=example_bash_operator --no-is-paused",
# DAG Run commands
"dagrun list --dag-id example_bash_operator --state success --limit=1",
+ # Task Instance commands
+ f'taskinstance list --dag-id=example_bash_operator
--dag-run-id="manual__{ONE_DATE_PARAM}"',
+ f'taskinstance get --dag-id=example_bash_operator
--dag-run-id="manual__{ONE_DATE_PARAM}" --task-id=runme_0',
Review Comment:
The tests only cover taskinstance list and taskinstance get. The clear and
update operations are untested and would benefit from integration test coverage
--
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]