Skip to content

Simplify DAG kwargs construction with a declarative spec#703

Open
gyli wants to merge 4 commits intoastronomer:mainfrom
gyli:simplify-dag-kwargs
Open

Simplify DAG kwargs construction with a declarative spec#703
gyli wants to merge 4 commits intoastronomer:mainfrom
gyli:simplify-dag-kwargs

Conversation

@gyli
Copy link
Copy Markdown
Contributor

@gyli gyli commented Apr 10, 2026

Resolves #587

Key changes:

  1. This PR uses dict-based declarative spec defining DAG arguments, achieving unified argument definition like version check.
  2. Always fall back to Airflow's own default value or behavior when key not set.

Future works: task-level spec will be added in the follow-up PR

@gyli gyli requested a review from a team as a code owner April 10, 2026 18:28
@gyli gyli requested review from pankajkoti and tatiana and removed request for a team April 10, 2026 18:28
@pankajastro pankajastro requested a review from Copilot April 14, 2026 08:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #587 by refactoring how DagBuilder constructs kwargs for the Airflow DAG constructor: it replaces imperative/default-setting logic with a declarative parameter spec so only explicitly configured DAG params are forwarded and Airflow’s own defaults remain in effect when values are not set.

Changes:

  • Introduces a module-level _DAG_PARAM_SPEC and a spec-driven DagBuilder._build_dag_kwargs() helper to construct dag_kwargs.
  • Removes DAG-kwarg defaulting previously sourced from Airflow config (e.g., catchup, max_active_runs, default_view), relying on Airflow constructor behavior when keys are absent.
  • Adds unit tests covering required params, deprecation mapping, Airflow version gating, and optional value transforms.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
dagfactory/dagbuilder.py Adds declarative DAG-kwarg spec and _build_dag_kwargs(), and wires build() to use it instead of setting defaults directly.
tests/test_dagbuilder.py Adds focused tests for _build_dag_kwargs() behaviors (presence-only forwarding, deprecations, version gates, transforms).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dagfactory/dagbuilder.py
Comment thread dagfactory/dagbuilder.py
Comment thread tests/test_dagbuilder.py Outdated
gyli and others added 3 commits April 16, 2026 21:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…LOW_VERSION

The warning messages in build_dag_kwargs were using the AIRFLOW_VERSION
string constant instead of INSTALLED_AIRFLOW_VERSION, which is the
actual parsed Version used for comparison. This made diagnostics
inaccurate when INSTALLED_AIRFLOW_VERSION is patched in tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove default value for dag_kwargs params

2 participants