-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to make expand task params as optional #182
Conversation
Make expand task params as optional, so not all tasks need to provide it. Currently, if there is no expand field in tasks YAML, it fails to generate the DAG from YAML. Also using expand creates a task mapping in airflow which doesn't not work when you want to use a branch operator to skip certain tasks based on the condition. Fix it here by making it optional.
Hey @ifulia, I dont think its actually fix. dag_name:
description: ""
schedule_interval: "50 9 * * *"
template_searchpath: ['/opt/airflow/dags/folder']
tasks:
task_1:
operator: operator.Operator
conn_id: 'conn_id'
task_2:
operator: airflow.operators.python_operator.PythonOperator
python_callable_name: python_callable
python_callable_file: /opt/airflow/plugins/utils.py
dependencies: [task_1]
task_3:
operator: airflow.operators.python_operator.PythonOperator
python_callable_name: prometheus_task
python_callable_file: /opt/airflow/plugins/utils.py
partial:
op_kwargs:
conn_id: "conn_id"
prometheus_url: "{{ conn.PROMETHEUS }}"
pg_host: "{{ conn.PG.host }}"
pg_schema: "{{ conn.PG.schema }}"
pg_login: "{{ conn.PG.login }}"
pg_password: "{{ conn.PG.password }}"
expand:
op_args:
task_2.output
dependencies:
- task_2 dag_name:
template_searchpath: ['/opt/airflow/dags/sql']
schedule_interval: "0 5 * * MON"
tasks:
task_1:
sql: 'insert_editor_event_week.sql'
operator: path_to_sql_operator.Operator
sql_truncate: 'alter.sql'
conn_id: 'conn_id'
params:
table: 'table_name'
delete_condition: 'timestamp' |
@matveykortsev Here is what I am using and getting error when creating dag.
The error I get is
|
@matveykortsev @ajbosco Could you please help merge this PR. |
@ajbosco @matveykortsev Could you please help review and merge this. This is blocking our use-case where we want to use only partial params. Let me know if you have any concerns. |
I still don’t understand of use case with partial but without expand. You can just pass params directly to operators then |
Ah, I didnt realize that you can pass it with params. I thought the only way to pass params is through partial and/or expand. This solves the problem. Thanks @matveykortsev |
Make expand task params as optional, so not all tasks need to provide it. Currently, if there is no expand field in tasks YAML, it fails to generate the DAG from YAML. Also using expand creates a task mapping in airflow which doesn't not work when you want to use a branch operator to skip certain tasks based on the condition. Fix it here by making it optional.