You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2023/01/03 17:40:16 UTC

[GitHub] [airflow] ephraimbuddy opened a new pull request, #28698: Fix "airflow tasks render" cli command for mapped task instances

ephraimbuddy opened a new pull request, #28698:
URL: https://github.com/apache/airflow/pull/28698

   The fix was to use the 'template_fields' attr directly since both mapped and unmapped tasks now have that attribute.
   I also had to use ti.task instead of the task from dag.get_task due to this error: `AttributeError: 'DecoratedMappedOperator' object has no attribute 'templates_dict'` and I wonder if this is a bug
   
   Closes: https://github.com/apache/airflow/issues/26555


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] ephraimbuddy commented on a diff in pull request #28698: Fix "airflow tasks render" cli command for mapped task instances

Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on code in PR #28698:
URL: https://github.com/apache/airflow/pull/28698#discussion_r1060830483


##########
airflow/cli/commands/task_command.py:
##########
@@ -594,21 +594,22 @@ def task_test(args, dag=None):
 
 @cli_utils.action_cli(check_db=False)
 @suppress_logs_and_warning
-def task_render(args):
+def task_render(args, dag=None):
     """Renders and displays templated fields for a given task."""
-    dag = get_dag(args.subdir, args.dag_id)
+    if not dag:
+        dag = get_dag(args.subdir, args.dag_id)
     task = dag.get_task(task_id=args.task_id)
     ti, _ = _get_ti(
         task, args.map_index, exec_date_or_run_id=args.execution_date_or_run_id, create_if_necessary="memory"
     )
     ti.render_templates()
-    for attr in task.__class__.template_fields:
+    for attr in task.template_fields:
         print(
             textwrap.dedent(
                 f"""        # ----------------------------------------------------------
         # property: {attr}
         # ----------------------------------------------------------
-        {getattr(task, attr)}
+        {getattr(ti.task, attr)}

Review Comment:
   @uranusjr , is it a bug that `DecoratedMappedOperator` does not have the `template_dict` attribute? That's the error I get if 'task' is used above instead of `ti.task`



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] ephraimbuddy merged pull request #28698: Fix "airflow tasks render" cli command for mapped task instances

Posted by GitBox <gi...@apache.org>.
ephraimbuddy merged PR #28698:
URL: https://github.com/apache/airflow/pull/28698


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on pull request #28698: Fix "airflow tasks render" cli command for mapped task instances

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #28698:
URL: https://github.com/apache/airflow/pull/28698#issuecomment-1370057637

   Good one :)


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org