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 2021/01/20 08:19:32 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #13767: Implement target provider versioning tools

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



##########
File path: dev/provider_packages/copy_provider_package_sources.py
##########
@@ -767,27 +781,38 @@ def do_refactor(self, in_process: bool = False) -> None:  # noqa
         self.refactor_kubernetes_pod_operator()
         # In order to debug Bowler - set in_process to True
         self.qry.execute(write=True, silent=False, interactive=False, in_process=in_process)
+        print("[green]OK[/]")
+
+
+def get_parser():
+    cli_parser = argparse.ArgumentParser(
+        description="Copies sources and optionally refactors provider code to be Airflow 1.10 compatible.",
+        formatter_class=argparse.RawTextHelpFormatter,
+    )
+    cli_parser.add_argument(
+        "--backports",
+        action='store_true',
+        help=textwrap.dedent("Includes refactoring to prepare backport packages rather than regular ones"),
+    )
+    cli_parser.add_argument(
+        "--debug",
+        action='store_true',
+        help=textwrap.dedent(
+            "Run bowler refactoring in single process. Makes it debuggable with regular"
+            " IDE debugger (much slower)"
+        ),
+    )
+    return cli_parser
 
 
 if __name__ == '__main__':
-    BACKPORT_PACKAGES = os.getenv('BACKPORT_PACKAGES') == "true"
-    in_process = False
-    if len(sys.argv) > 1:
-        if sys.argv[1] in ['--help', '-h']:
-            print()
-            print("Refactors provider packages to be Airflow 1.10 compatible.")
-            print()
-            print(f"Usage: {sys.argv[0]} [--debug] | [-h] | [--help]")
-            print()
-            print("You can use --debug flag in order to run bowler refactoring in process.")
-            print("This allows you to debug bowler process as usual using your IDE debugger")
-            print("Otherwise it heavily uses multi-processing and is next-to-impossible to debug")
-            print()
-            print("Note - Bowler is also a lot slower in this mode.")
-            print()
-            sys.exit(0)
-        if sys.argv[1] == '--debug':
-            in_process = True
-    copy_provider_sources()
-    if BACKPORT_PACKAGES:
+    parser = get_parser()
+    args = parser.parse_args()
+
+    in_process = args.debug
+    copy_provider_sources(args.backports)
+    os.chdir(get_target_providers_folder())
+    if args.backports:
+        print("\nRefactoring code to be Airflow 1.10 - compatible\n")

Review comment:
       Not sure but maybe we may use `end='\n\n'` instead of new lines in string?




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