samraj2k commented on code in PR #74915:
URL: https://github.com/apache/airflow/pull/74915#discussion_r4727470070
##########
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:
Got it, this is inline with interface and then multiple impl in future. I
have followed the model in the PR. _BaseBundleConfigSource is the base with two
impl, one static and one dynamic.
One diff is that, in the impl, the lifecycle classes are module level
classes that lifecycle class refers to, rather than nested classes.
--
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]