nathadfield opened a new pull request, #61063:
URL: https://github.com/apache/airflow/pull/61063

   # Add configurable bundle version defaults
   
   ## Summary
   
   This PR adds the ability to configure default bundle version behavior at 
three levels with a clear precedence hierarchy. Users can now set 
organization-wide, per-DAG, or per-operator defaults for whether DAG runs 
should use the latest bundle version or the original version, eliminating the 
need to specify this on every clear/rerun operation.
   
   Additionally, this PR adds the `run_on_latest_version` parameter to 
`TriggerDagRunOperator`, allowing explicit control when triggering child DAGs 
programmatically.
   
   ## What Changed
   
   ### 1. Global Configuration
   Added `[core] run_on_latest_version` configuration option that applies 
organization-wide default behavior.
   
   ```ini
   [core]
   run_on_latest_version = True
   ```
   
   ### 2. DAG-Level Configuration
   Added `run_on_latest_version` parameter to the DAG class that overrides 
global configuration for specific DAGs.
   
   ```python
   with DAG(dag_id="my_dag", run_on_latest_version=True, ...) as dag:
       ...
   ```
   
   ### 3. Operator-Level Control
   Added `run_on_latest_version` parameter to `TriggerDagRunOperator` with 
highest precedence, overriding both DAG and global configuration.
   
   ```python
   trigger = TriggerDagRunOperator(
       task_id="trigger_latest",
       trigger_dag_id="target_dag",
       run_on_latest_version=True,
   )
   ```
   
   ### 4. UI Integration
   Configured existing "Run on Latest Version" checkboxes in all three Clear 
dialogs (Run, Task Instance, Task Group) to respect the configuration 
hierarchy. Checkboxes now default based on precedence: DAG-level > Global > 
System.
   
   ### 5. Precedence Hierarchy
   
   ```
   Operator Level > DAG Level > Global Level > System Default (original version)
   ```
   
   ## Implementation Details
   
   ### Backend Changes (9 files)
   - **Configuration**: Added new config option with documentation
   - **DAG Definition**: Added parameter to DAG class and serialization
   - **Resolution Logic**: Implemented precedence hierarchy in 
`_resolve_bundle_version()`
   - **API Layer**: Exposed configuration and bundle version fields in responses
   - **Error Handling**: Improved logging with INFO/ERROR/WARNING levels based 
on context
   
   ### Operator Changes (1 file)
   - **TriggerDagRunOperator**: Added `run_on_latest_version` parameter
   - **Supervisor Integration**: Forwards bundle_version to API client
   - **API Client**: Accepts and passes bundle_version parameter
   
   ### UI Changes (3 files)
   - **Clear Dialogs**: Implemented precedence hierarchy for checkbox defaults
   - **Configuration Fetch**: Added `useConfig()` integration
   - **Dynamic Updates**: Added `useEffect` to sync state when config loads
   
   ### Test Coverage (3 files)
   - Added tests for global config API
   - Added tests for DAG-level configuration
   - Added tests for precedence hierarchy resolution
   - Added integration tests for supervisor → API → database flow
   - Fixed SQLAlchemy deprecation warnings
   
   ### Documentation (1 file)
   - Updated dag-bundles.rst with comprehensive examples
   - Documented precedence hierarchy
   - Added configuration reference
   
   ## Use Cases
   
   ### Use Case 1: Organization-Wide Default
   Set global config to True so all DAG runs use the latest bundle version by 
default.
   
   ### Use Case 2: Critical DAG Exception
   Override global config at DAG level for critical DAGs that must use original 
version for compliance.
   
   ### Use Case 3: Specific Task Override
   Override at operator level to test original version while other tasks use 
latest.
   
   ## Testing
   
   ### Unit Tests
   - ✅ Config API tests (2 new tests)
   - ✅ DAG resolution tests (5 new tests)
   - ✅ Supervisor forwarding tests (3 tests including new bundle_version test)
   - ✅ API client tests (3 tests)
   - ✅ Serialization tests
   
   ### Manual Testing
   - ✅ Checkbox defaults respect precedence hierarchy
   - ✅ TriggerDagRunOperator passes bundle version correctly
   - ✅ AF2 compatibility maintained (bundle versioning ignored)
   - ✅ AF3 functionality working
   
   ## Backward Compatibility
   
   **✅ Fully backward compatible**:
   - All new configuration defaults to `False` (preserves current behavior)
   - No database schema changes required
   - No breaking changes to existing APIs
   - UI enhancements are progressive
   - Non-versioned bundles (LocalDagBundle) unaffected
   
   ## Migration
   
   **No migration required!** The feature is completely opt-in:
   1. Default behavior preserved (use original bundle version)
   2. Enable at global, DAG, or operator level as needed
   3. No database changes or data migration
   
   ## Related Issues
   
   - Closes #60880: TriggerDagRunOperator bundle version parameters
   - Closes #60887: Global and DAG-level bundle version defaults
   
   ## Breaking Changes
   
   **None**
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Sonnet 4.5 following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to