uranusjr commented on code in PR #74915:
URL: https://github.com/apache/airflow/pull/74915#discussion_r4676454409


##########
airflow-core/src/airflow/dag_processing/bundles/manager.py:
##########
@@ -113,35 +120,209 @@ def _bundle_item_exc(msg):
 class _BundleConfigSnapshot(NamedTuple):
     """The configured Dag bundles, as names only and as full configs."""
 
-    configs: tuple[_ExternalBundleConfig, ...]
+    configs: dict[str, _ExternalBundleConfig]
     names: frozenset[str]
+    team_names: dict[str, str | None]
+
+
+def _find_changed_bundle(adopted: _BundleConfigSnapshot, candidate: 
_BundleConfigSnapshot) -> str | None:
+    if candidate is adopted:
+        return None
+    return next(
+        (
+            name
+            for name in adopted.configs.keys() & candidate.configs.keys()
+            if adopted.configs[name] != candidate.configs[name]
+        ),
+        None,
+    )
 
 
[email protected]
-def _load_bundle_config_snapshot() -> _BundleConfigSnapshot:
-    """Read and validate the configured Dag bundles, without importing their 
classes."""
-    bundle_config_list = _read_bundle_config_list()
-    if not bundle_config_list:
-        return _BundleConfigSnapshot(configs=(), names=frozenset())
-    if conf.getboolean("core", "LOAD_EXAMPLES"):
+def _bundle_definition_changed(name: str) -> AirflowConfigException:
+    return _bundle_item_exc(
+        f"Configuration for bundle '{name}' has changed. Rejecting the entire "
+        "configuration list and keeping the last accepted list. "
+        "Revert this entry or use a new bundle name."
+    )
+
+
+def _create_bundle_config_snapshot(bundle_config_list: 
list[_ExternalBundleConfig]) -> _BundleConfigSnapshot:
+    """Validate the configured Dag bundles, without importing their classes."""
+    team_names = {cfg.name: cfg.team_name for cfg in bundle_config_list}
+    if bundle_config_list and conf.getboolean("core", "LOAD_EXAMPLES"):
         _add_example_dag_bundle(bundle_config_list)
         _add_provider_example_dags_to_bundle(bundle_config_list)
     return _BundleConfigSnapshot(
-        configs=tuple(bundle_config_list),
+        configs={cfg.name: cfg for cfg in bundle_config_list},
         names=frozenset(cfg.name for cfg in bundle_config_list),
+        team_names=team_names,
+    )
+
+
+def _build_internal_bundle_config(config: _ExternalBundleConfig) -> 
_InternalBundleConfig:
+    if config.team_name and not conf.getboolean("core", "multi_team"):
+        raise AirflowConfigException(
+            "Section `dag_processor` key `dag_bundle_config_list` "
+            "cannot have a team name when multi-team mode is disabled."
+            "To enable multi-team, you need to update section `core` key 
`multi_team` in your config."
+        )
+    return _InternalBundleConfig(
+        bundle_class=import_string(config.classpath),
+        kwargs=config.kwargs,
+        team_name=config.team_name,
+        importers=config.importers,
     )
 
 
+class _StaticBundleConfigSource:
+    """The bundle configuration of this process, read from 
``dag_bundle_config_list`` on first use."""
+
+    reconcilable: ClassVar[bool] = False

Review Comment:
   This now decides a lot of things. I’m thinking we can do it somehow like this
   
   ```python
   class _BaseLifecycle:
       def __init__(self, processor: DagFileProcessorManager) -> None: ...
       def check_supported(self) -> None: ...
       def reconcile(self, known_files: dict[str, set[DagFileInfo]]) -> None: 
...
       def cleanup(self) -> None: ...
   
   class _BaseBundleConfigSource:
       lifecycle_class: ClassVar[type[_BaseBundleLifecycle]]
       def parse_context(self, name: str) -> BundleParseContext | None: ...
       def get_bundle_teams(self) -> dict[str, str | None]: ...
   
   class _StaticBundleConfigSource(_BaseBundleConfigSource):
       class lifecycle_class(_BaseLifecycle): ...
       # Implementat methods...
   
   class _ReloadingBundleConfigSource(_BaseBundleConfigSource):
       class lifecycle_class(_BaseLifecycle): ...
       # Implementat methods...
   ```
   
   this would gather logic all onto the bundle config source classes instead of 
scattered around with a flag check. It’s also clearer that the static and 
reloading sources are two separate things, reloading does not subclass (“is 
kind of”) static.



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