raviagarwalunravel commented on a change in pull request #5118: [AIRFLOW-4315]
Add monitoring API's to airflow
URL: https://github.com/apache/airflow/pull/5118#discussion_r280701170
##########
File path: airflow/api/common/experimental/get_task.py
##########
@@ -38,3 +38,19 @@ def get_task(dag_id, task_id):
# Return the task.
return dag.get_task(task_id)
+
+
+def get_task_as_dict(dag_id, task_id):
+ """Return the task object as a dictionary identified by the given dag_id
and task_id"""
+ try:
+ task = get_task(dag_id, task_id)
+ fields = {k: str(v)
+ for k, v in vars(task).items()
+ if not k.startswith('_')}
+ fields.update({
+ 'upstream_task_ids': list(task._upstream_task_ids),
+ 'downstream_task_ids': list(task._downstream_task_ids)})
+ except AirflowException as err:
+ raise err
Review comment:
done.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services