potiuk commented on code in PR #32604:
URL: https://github.com/apache/airflow/pull/32604#discussion_r1268165435
##########
airflow/configuration.py:
##########
@@ -136,30 +139,121 @@ def _default_config_file_path(file_name: str) -> str:
return os.path.join(templates_dir, file_name)
-def default_config_yaml() -> dict[str, Any]:
+def default_configuration_description(
+ include_airflow: bool = True,
+ include_providers: bool = True,
+ selected_provider: str | None = None,
+ config_file_name: str = "config.yml",
+) -> dict[str, dict[str, Any]]:
"""
- Read Airflow configs from YAML file.
+ Read Airflow configs from YAML file, and merge them with provider configs
optionally.
+ :param include_airflow: Include Airflow configs
+ :param include_providers: Include provider configs
+ :param selected_provider: If specified, include selected provider only
+ :param config_file_name: name of the file in "config_templates" directory
to read default config from
:return: Python dictionary containing configs & their info
"""
- with open(_default_config_file_path("config.yml")) as config_file:
- return yaml.safe_load(config_file)
+ base_configuration_description: dict[str, dict[str, Any]] = {}
+ if include_airflow:
+ with open(_default_config_file_path(config_file_name)) as config_file:
+ base_configuration_description.update(yaml.safe_load(config_file))
+ if include_providers:
+ from airflow.providers_manager import ProvidersManager
+
+ for provider, config in ProvidersManager().provider_configs:
+ if selected_provider and provider != selected_provider:
+ continue
+ base_configuration_description.update(config)
+ return base_configuration_description
+
+
+def dejinjafy(value: Any) -> str:
+ if isinstance(value, str):
+ if "{{{{" in value:
+ return value.replace("{{{{", "{{").replace("}}}}", "}}")
+ return value.replace("{{", "{").replace("}}", "}")
+ return value
class AirflowConfigParser(ConfigParser):
"""Custom Airflow Configparser supporting defaults and deprecated
options."""
+ def __init__(
+ self,
+ default_config: str | dict[str, dict[str, Any]] | None = None,
+ default_config_description: dict[str, dict[str, Any]] | None = None,
+ *args,
+ **kwargs,
+ ):
+ super().__init__(*args, **kwargs)
+ self.default_config_description = default_config_description
+ self.upgraded_values = {}
+ self._default_values: dict[str, dict[str, Any]] = {}
+ if default_config is not None:
Review Comment:
It is addressed now I think :)
--
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]