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

   Closes: #57355
   
   # Why
   
   When a user uses `airflow config list --include-descriptions 
--include-examples` to generate new configurations, they would encounter a 
`configparser.ParsingError` caused by indentation.
   
   <img width="702" height="256" alt="image" 
src="https://github.com/user-attachments/assets/8411c3f2-8457-4219-a91a-46a0e7d9a753";
 />
   
   # How
   
   Although we have the `--defaults` flag, it produces output with the correct 
indentation but with comments.
   
   <img width="676" height="424" alt="image" 
src="https://github.com/user-attachments/assets/d8885d86-d12f-4022-96f5-b31ed783d332";
 />
   
   This causes `comment_out_everything` to always be `True`.
   
   
https://github.com/apache/airflow/blob/14c7fedef5acd1ae8d50be093e9ef81a96fda6bf/airflow-core/src/airflow/cli/commands/config_command.py#L49
   
   Therefore, I added a flag `--defaults-no-comments` to generate default 
configuration without comments.
   
   # What
   
   ```console
   root@a76315950982:/opt/airflow# airflow config list --include-descriptions 
--include-examples --defaults-no-comments | grep "dag_bundle_config_list" -A 10
   # Example: dag_bundle_config_list = [
   #       {
   #         "name": "my-git-repo",
   #         "classpath": "airflow.providers.git.bundles.git.GitDagBundle",
   #         "kwargs": {
   #           "subdir": "dags",
   #           "tracking_ref": "main",
   #           "refresh_interval": 0
   #         }
   #       }
   #     ]
   dag_bundle_config_list = [
         {
           "name": "dags-folder",
           "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle",
           "kwargs": {}
         }
       ]
   
   
   # How often (in seconds) to refresh, or look for new files, in a DAG bundle.
   refresh_interval = 300
   root@a76315950982:/opt/airflow# python - <<'PY'
   import configparser, pathlib, sys
   p = configparser.ConfigParser()
   p.read(pathlib.Path("airflow_new.cfg"))
   PY
   root@a76315950982:/opt/airflow# 
   ```
   
   # Discussion
   
   I'm not sure why the `or` operator is needed here, but if we can tweak it to 
`comment_out_everything = args.comment_out_everything`, then I think my flag 
`--defaults-no-comments` can be removed.
   
   
https://github.com/apache/airflow/blob/14c7fedef5acd1ae8d50be093e9ef81a96fda6bf/airflow-core/src/airflow/cli/commands/config_command.py#L49


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