You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2023/02/17 10:40:26 UTC

[GitHub] [airflow] potiuk commented on a diff in pull request #29586: fix template_fields in the decorator `task.docker`

potiuk commented on code in PR #29586:
URL: https://github.com/apache/airflow/pull/29586#discussion_r1109605587


##########
tests/providers/docker/decorators/test_docker.py:
##########
@@ -60,6 +60,21 @@ def f(num_results):
         assert isinstance(result, list)
         assert len(result) == 50
 
+    def test_basic_docker_operator_with_template_fields(self, dag_maker):
+        @task.docker(image="python:3.9-slim", container_name='python_{{macros.datetime.now() | ts_nodash}}')
+        def f():
+            import random
+
+            return [random.random() for _ in range(100)]
+
+        with dag_maker():
+            ret = f()
+
+        dr = dag_maker.create_dagrun()
+        ret.operator.run(start_date=dr.execution_date, end_date=dr.execution_date)
+        ti = dr.get_task_instances()[0]
+        assert len(ti.xcom_pull()) == 100
+        

Review Comment:
   But we evaluate that it actually run, which means that the JINJA has been processed, otherwise we would have "invalid name" (as in the original request). Good enough for me TBH



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