You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/11/28 12:44:47 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #12657: Add possibility to configure upgrade_check command

turbaszek commented on a change in pull request #12657:
URL: https://github.com/apache/airflow/pull/12657#discussion_r532036258



##########
File path: airflow/upgrade/checker.py
##########
@@ -45,19 +46,44 @@ def register_arguments(subparser):
         "-s", "--save",
         help="Saves the result to the indicated file. The file format is determined by the file extension."
     )
+    subparser.add_argument(
+        "-i", "--ignore",
+        help="Ignore a rule. Can be used multiple times.",
+        action='append',
+    )
+    subparser.add_argument(
+        "-c", "--config",
+        help="Path to upgrade check config yaml file.",
+    )
     subparser.set_defaults(func=run)
 
 
 def run(args):
     from airflow.upgrade.formatters import (ConsoleFormatter, JSONFormatter)
+    from airflow.upgrade.config import UpgradeConfig
+
     if args.save:
         filename = args.save
         if not filename.lower().endswith(".json"):
             exit("Only JSON files are supported")
         formatter = JSONFormatter(args.save)
     else:
         formatter = ConsoleFormatter()
-    all_problems = check_upgrade(formatter)
+
+    if args.ignore:
+        rules = [r for r in ALL_RULES if r.__class__.__name__ not in args.ignore]
+    else:
+        rules = ALL_RULES
+
+    if args.config:
+        print("Using config file from:", args.config)
+        upgrade_config = UpgradeConfig.read(path=args.config)
+        rules = upgrade_config.register_custom_rules(rules)
+        rules = upgrade_config.remove_ignored_rules(rules)
+
+    logging.disable(logging.WARNING)

Review comment:
       > You're going to have to explain why this line is here.
   
   @ashb should I add comment in code?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org