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 2022/04/07 20:14:47 UTC

[GitHub] [airflow] tronlightracer opened a new issue, #22843: When passing the 'False' value to the parameters of a decorated dag function I get this traceback

tronlightracer opened a new issue, #22843:
URL: https://github.com/apache/airflow/issues/22843

   ### Apache Airflow version
   
   2.2.3
   
   ### What happened
   
   When passing the `False` value to a decorated dag function I get this traceback below. Also the default value is not shown when clicking 'trigger dag w/ config'.
   
   
   ```[2022-04-07, 20:08:57 UTC] {taskinstance.py:1259} INFO - Executing <Task(_PythonDecoratedOperator): value_consumer> on 2022-04-07 20:08:56.914410+00:00
   [2022-04-07, 20:08:57 UTC] {standard_task_runner.py:52} INFO - Started process 2170 to run task
   [2022-04-07, 20:08:57 UTC] {standard_task_runner.py:76} INFO - Running: ['airflow', 'tasks', 'run', 'check_ui_config', 'value_consumer', 'manual__2022-04-07T20:08:56.914410+00:00', '--job-id', '24', '--raw', '--subdir', 'DAGS_FOLDER/check_ui_config.py', '--cfg-path', '/tmp/tmpww9euksv', '--error-file', '/tmp/tmp7kjdfks5']
   [2022-04-07, 20:08:57 UTC] {standard_task_runner.py:77} INFO - Job 24: Subtask value_consumer
   [2022-04-07, 20:08:57 UTC] {logging_mixin.py:109} INFO - Running <TaskInstance: check_ui_config.value_consumer manual__2022-04-07T20:08:56.914410+00:00 [running]> on host a643f8828615
   [2022-04-07, 20:08:57 UTC] {taskinstance.py:1700} ERROR - Task failed with exception
   Traceback (most recent call last):
     File "/usr/local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 1329, in _run_raw_task
       self._execute_task_with_callbacks(context)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 1418, in _execute_task_with_callbacks
       self.render_templates(context=context)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 1992, in render_templates
       self.task.render_template_fields(context)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1061, in render_template_fields
       self._do_render_template_fields(self, self.template_fields, context, jinja_env, set())
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1074, in _do_render_template_fields
       rendered_content = self.render_template(content, context, jinja_env, seen_oids)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1125, in render_template
       return tuple(self.render_template(element, context, jinja_env) for element in content)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1125, in <genexpr>
       return tuple(self.render_template(element, context, jinja_env) for element in content)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1116, in render_template
       return content.resolve(context)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/param.py", line 226, in resolve
       raise AirflowException(f'No value could be resolved for parameter {self._name}')
   airflow.exceptions.AirflowException: No value could be resolved for parameter test
   [2022-04-07, 20:08:57 UTC] {taskinstance.py:1267} INFO - Marking task as FAILED. dag_id=check_ui_config, task_id=value_consumer, execution_date=20220407T200856, start_date=20220407T200857, end_date=20220407T200857
   [2022-04-07, 20:08:57 UTC] {standard_task_runner.py:89} ERROR - Failed to execute job 24 for task value_consumer
   Traceback (most recent call last):
     File "/usr/local/lib/python3.9/site-packages/airflow/task/task_runner/standard_task_runner.py", line 85, in _start_by_fork
       args.func(args, dag=self.dag)
     File "/usr/local/lib/python3.9/site-packages/airflow/cli/cli_parser.py", line 48, in command
       return func(*args, **kwargs)
     File "/usr/local/lib/python3.9/site-packages/airflow/utils/cli.py", line 92, in wrapper
       return f(*args, **kwargs)
     File "/usr/local/lib/python3.9/site-packages/airflow/cli/commands/task_command.py", line 298, in task_run
       _run_task_by_selected_method(args, dag, ti)
     File "/usr/local/lib/python3.9/site-packages/airflow/cli/commands/task_command.py", line 107, in _run_task_by_selected_method
       _run_raw_task(args, ti)
     File "/usr/local/lib/python3.9/site-packages/airflow/cli/commands/task_command.py", line 180, in _run_raw_task
       ti._run_raw_task(
     File "/usr/local/lib/python3.9/site-packages/airflow/utils/session.py", line 70, in wrapper
       return func(*args, session=session, **kwargs)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 1329, in _run_raw_task
       self._execute_task_with_callbacks(context)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 1418, in _execute_task_with_callbacks
       self.render_templates(context=context)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 1992, in render_templates
       self.task.render_template_fields(context)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1061, in render_template_fields
       self._do_render_template_fields(self, self.template_fields, context, jinja_env, set())
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1074, in _do_render_template_fields
       rendered_content = self.render_template(content, context, jinja_env, seen_oids)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1125, in render_template
       return tuple(self.render_template(element, context, jinja_env) for element in content)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1125, in <genexpr>
       return tuple(self.render_template(element, context, jinja_env) for element in content)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 1116, in render_template
       return content.resolve(context)
     File "/usr/local/lib/python3.9/site-packages/airflow/models/param.py", line 226, in resolve
       raise AirflowException(f'No value could be resolved for parameter {self._name}')
   airflow.exceptions.AirflowException: No value could be resolved for parameter test
   ```
   
   ### What you think should happen instead
   
   I think airflow should be able to handle the False value when passing it as a dag param.
   
   ### How to reproduce
   
   from airflow.decorators import dag, task
   from airflow.models.param import Param
   
   from datetime import datetime, timedelta
   
   
   @task
   def value_consumer(val):
       print(val)
   
   
   @dag(
       start_date=datetime(2021, 1, 1),
       schedule_interval=timedelta(days=365, hours=6)
   )
   def check_ui_config(test):
       value_consumer(test)
       
   
   the_dag = check_ui_config(False)
   
   ### Operating System
   
   Docker (debian:buster)
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Astronomer
   
   ### Deployment details
   
   Astro cli with this image:
   quay.io/astronomer/ap-airflow-dev:2.2.3-2
   
   ### Anything else
   
   ![Screenshot from 2022-04-07 14-13-43](https://user-images.githubusercontent.com/102494105/162288264-bb6c6ca6-977f-4ff7-a0cc-9616c0ce8ac8.png)
   
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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.apache.org

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


[GitHub] [airflow] MatrixManAtYrService commented on issue #22843: When passing the 'False' value to the parameters of a decorated dag function I get this traceback

Posted by GitBox <gi...@apache.org>.
MatrixManAtYrService commented on issue #22843:
URL: https://github.com/apache/airflow/issues/22843#issuecomment-1092301293

   This appears to be the case for any falsey value.  Consider this dag:
   
   ```python3
   @dag
   def paramstuff(x, a=Param(2, minimum=0)):
       @task
       def add(literal, dagparam):
           print(literal + dagparam)
   
       add(x, a)
   
   
   # the_dag = paramstuff(0)  # one dag arg, 'add' says:
   # AirflowException: No value could be resolved for parameter x
   
   the_dag = paramstuff(3)  # two dag args, 'add' says 5
   ```
   
   I'm not sure how we should treat positional args being passed into `@dag` decorated functions (I'm tempted to say that they shouldn't interact with DagParams at all, leave that to the kwargs).  But whatever we do, it probably shouldn't depend on whether those values are falsey.


-- 
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] MatrixManAtYrService commented on issue #22843: When passing the 'False' value to the parameters of a decorated dag function I get this traceback

Posted by GitBox <gi...@apache.org>.
MatrixManAtYrService commented on issue #22843:
URL: https://github.com/apache/airflow/issues/22843#issuecomment-1092280928

   My initial feeling is that positional args on dag decorated functions should not be interpreted as dag params, so you could do things like this:
   
   ```python3
   @task
   some_task(arg):
       ....
   
   @task
   some_other_task(arg):
       ....
   
   @dag
   def func(extra_step, arg=Param(6, minimum=0, maximum=10):
       some_task(arg)
       if extra_step:
           some_other_task(art)
           
    one_dag = func(True)
    another_dag = func(False)
   ```
   
   But I'm interested to hear what others think.


-- 
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] uranusjr closed issue #22843: When passing the 'False' value to the parameters of a decorated dag function I get this traceback

Posted by GitBox <gi...@apache.org>.
uranusjr closed issue #22843: When passing the 'False' value to the parameters of a decorated dag function I get this traceback
URL: https://github.com/apache/airflow/issues/22843


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