]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
scripts: Delay imports for performance
authorZack Cerza <zack@cerza.org>
Thu, 10 Apr 2025 19:22:08 +0000 (13:22 -0600)
committerZack Cerza <zack@cerza.org>
Wed, 2 Jul 2025 02:51:55 +0000 (20:51 -0600)
Signed-off-by: Zack Cerza <zack@cerza.org>
scripts/dispatcher.py
scripts/exporter.py
scripts/lock.py
scripts/ls.py
scripts/prune_logs.py
scripts/report.py
scripts/results.py
scripts/schedule.py
scripts/supervisor.py
scripts/updatekeys.py

index 45dd61b264851ad8c7cd8569433ddd20f445efbe..2d84300913219a8e150a7d22357641f5f62012cf 100644 (file)
@@ -1,8 +1,6 @@
 import argparse
 import sys
 
-import teuthology.dispatcher.supervisor
-
 from .supervisor import parse_args as parse_supervisor_args
 
 
@@ -46,6 +44,7 @@ def parse_args(argv):
 
 def main():
     if "--supervisor" in sys.argv:
+        import teuthology.dispatcher.supervisor
         # This is for transitional compatibility, so the old dispatcher can
         # invoke the new supervisor. Once old dispatchers are phased out,
         # this block can be as well.
@@ -55,7 +54,9 @@ def main():
             parse_supervisor_args(sys.argv[1:])
         ))
     else:
-        sys.exit(teuthology.dispatcher.main(parse_args(sys.argv[1:])))
+        args = parse_args(sys.argv[1:])
+        import teuthology.dispatcher
+        sys.exit(teuthology.dispatcher.main(args))
 
 
 if __name__ == "__main__":
index 438d5d3f3243d4a846809ec506a45ce03731bbf9..a886c9c7a791054039380bdf499cb31ab6cc6b82 100644 (file)
@@ -1,7 +1,5 @@
 import docopt
 
-import teuthology.exporter
-
 doc = """
 usage: teuthology-exporter --help
        teuthology-exporter [--interval INTERVAL]
@@ -15,4 +13,5 @@ optional arguments:
 
 def main():
     args = docopt.docopt(doc)
+    import teuthology.exporter
     teuthology.exporter.main(args)
index 69e50ccafbdc33a46890a305e2d63884733c5dea..7915cc99392fffc3b918a5126cd9db7c77b1a718 100644 (file)
@@ -2,9 +2,6 @@ import argparse
 import textwrap
 import sys
 
-import teuthology.lock
-import teuthology.lock.cli
-
 
 def _positive_int(string):
     value = int(string)
@@ -15,7 +12,10 @@ def _positive_int(string):
 
 
 def main():
-    sys.exit(teuthology.lock.cli.main(parse_args(sys.argv[1:])))
+    args = parse_args(sys.argv[1:])
+    import teuthology.lock
+    import teuthology.lock.cli
+    sys.exit(teuthology.lock.cli.main(args))
 
 
 def parse_args(argv):
index 5c9b33be3608798fe8d2565a4209d83bd44b92c8..71edcada9a57a4da1cdd69ab2c9e3920cfe5abdc 100644 (file)
@@ -11,9 +11,8 @@ optional arguments:
   -v, --verbose  show reasons tests failed
 """
 import docopt
-import teuthology.ls
-
 
 def main():
     args = docopt.docopt(__doc__)
+    import teuthology.ls
     teuthology.ls.main(args)
index 424b4b7b7d238baf5c669ec1eab92ad74bea11e6..4d2a638c68d1e00f60497dc09504c8b919c49958 100644 (file)
@@ -1,7 +1,6 @@
 import docopt
 
 import teuthology.config
-import teuthology.prune
 
 doc = """
 usage:
@@ -35,4 +34,5 @@ optional arguments:
 
 def main():
     args = docopt.docopt(doc)
+    import teuthology.prune
     teuthology.prune.main(args)
index d2b39d3c5a96f2f079b3129ca3fd20b48ee995d1..aa969bd14959206a6560043aa8d011e3dfb3666d 100644 (file)
@@ -1,6 +1,7 @@
 import docopt
 
-import teuthology.report
+import teuthology.config
+
 
 doc = """
 usage:
@@ -39,4 +40,5 @@ optional arguments:
 
 def main():
     args = docopt.docopt(doc)
+    import teuthology.report
     teuthology.report.main(args)
index 99e70a3fd0c5b2498001edb1bdbb3cbbcb4ecc71..2deca5f5a62c891f6681e41f9cd641708686b0a5 100644 (file)
@@ -17,9 +17,9 @@ optional arguments:
   --no-nested-subset    disable nested subsets used in teuthology-suite
 """
 import docopt
-import teuthology.results
 
 
 def main():
     args = docopt.docopt(__doc__)
+    import teuthology.results
     teuthology.results.main(args)
index 58f7a46249dfbf0e291824f6420a9fb0cb0abcfd..dcdacb515cd8b9dbd3389c90bca53c48a0294e0e 100644 (file)
@@ -1,7 +1,4 @@
 import docopt
-
-import teuthology.misc
-import teuthology.schedule
 import sys
 
 doc = """
@@ -58,4 +55,6 @@ optional arguments:
 
 def main(argv=sys.argv[1:]):
     args = docopt.docopt(doc, argv=argv)
+    import teuthology.misc
+    import teuthology.schedule
     teuthology.schedule.main(args)
index 7450473eb1449548fbf4e45bccf77dd96c1f73bf..90691f19f3e8cdf618f9b4af215ff3e88498b38e 100644 (file)
@@ -1,8 +1,6 @@
 import argparse
 import sys
 
-import teuthology.dispatcher.supervisor
-
 
 def parse_args(argv):
     parser = argparse.ArgumentParser(
@@ -37,7 +35,9 @@ def parse_args(argv):
 
 
 def main():
-    sys.exit(teuthology.dispatcher.supervisor.main(parse_args(sys.argv[1:])))
+    args = parse_args(sys.argv[1:])
+    import teuthology.dispatcher.supervisor
+    sys.exit(teuthology.dispatcher.supervisor.main(args))
 
 
 if __name__ == "__main__":
index 394ae32bb1734dca1315a3aa7b9958bed428e4e4..36d601dde08cb66dcdc96539ce3a1cabe4da4756 100644 (file)
@@ -1,9 +1,6 @@
 import docopt
 import sys
 
-import teuthology.lock
-import teuthology.lock.cli
-
 doc = """
 usage: teuthology-updatekeys -h
        teuthology-updatekeys [-v] -t <targets>
@@ -27,5 +24,7 @@ optional arguments:
 
 def main():
     args = docopt.docopt(doc)
+    import teuthology.lock
+    import teuthology.lock.cli
     status = teuthology.lock.cli.updatekeys(args)
     sys.exit(status)