You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "hussein-awala (via GitHub)" <gi...@apache.org> on 2023/04/10 14:53:46 UTC

[GitHub] [airflow] hussein-awala commented on a diff in pull request #29913: Fix mapped tasks partial arguments when DAG default args are provided

hussein-awala commented on code in PR #29913:
URL: https://github.com/apache/airflow/pull/29913#discussion_r1161790649


##########
airflow/models/baseoperator.py:
##########
@@ -292,34 +312,11 @@ def partial(
         "doc_yaml": doc_yaml,
     }
 
-    DEFAULT_VALUES: dict[str, Any] = {
-        "owner": DEFAULT_OWNER,
-        "trigger_rule": DEFAULT_TRIGGER_RULE,
-        "depends_on_past": False,
-        "ignore_first_depends_on_past": DEFAULT_IGNORE_FIRST_DEPENDS_ON_PAST,
-        "wait_for_past_depends_before_skipping": DEFAULT_WAIT_FOR_PAST_DEPENDS_BEFORE_SKIPPING,
-        "wait_for_downstream": False,
-        "retries": DEFAULT_RETRIES,
-        "queue": DEFAULT_QUEUE,
-        "pool_slots": DEFAULT_POOL_SLOTS,
-        "execution_timeout": DEFAULT_TASK_EXECUTION_TIMEOUT,
-        "retry_delay": DEFAULT_RETRY_DELAY,
-        "retry_exponential_backoff": False,
-        "priority_weight": DEFAULT_PRIORITY_WEIGHT,
-        "weight_rule": DEFAULT_WEIGHT_RULE,
-        "inlets": [],
-        "outlets": [],
-    }
+    # Populate kwargs from DAG-level default args.
+    partial_kwargs.update((k, v) for k, v in dag_default_args.items() if partial_kwargs.get(k) is NOTSET)
 
-    # Override NOTSET kwargs by dag default values
-    for k, v in default_partial_kwargs.items():
-        if partial_kwargs.get(k) is NOTSET:
-            partial_kwargs[k] = v
-
-    # Override NOTSET kwargs which don't have a dag default value by Airflow default value or None
-    partial_kwargs = {
-        k: v if v is not NOTSET else DEFAULT_VALUES.get(k, None) for k, v in partial_kwargs.items()
-    }
+    # Populate kwargs from Airflow default constants.
+    partial_kwargs.update((k, v) for k, v in _PARTIAL_DEFAULTS.items() if partial_kwargs.get(k) is NOTSET)

Review Comment:
   @uranusjr I'm not sure if this is safe.
   the previous version was replacing the the value `NOTSET` by `None` if it doesn't have a default value in `DEFAULT_VALUES`, but this version loops over the `_PARTIAL_DEFAULTS` and replaces only the `NOTSET` values which have a default value by the default ones. (ex: `doc_*`, `on_*_callback`, ...), I don't think the base operator is able to process `NOTSET` without any problem.
   WDYT?



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