Rename timer; add a test for OutputContext.
[python_utils.git] / executors.py
index 2b2f0252ce326fd34800080735f5324f91bfc315..2f4cf8314fdb07c536c75999fa40ecd83781cb05 100644 (file)
@@ -21,10 +21,9 @@ import cloudpickle  # type: ignore
 from ansi import bg, fg, underline, reset
 import argparse_utils
 import config
-import exec_utils
+from exec_utils import run_silently, cmd_in_background
 from decorator_utils import singleton
 import histogram
-import string_utils
 
 logger = logging.getLogger(__name__)
 
@@ -599,14 +598,14 @@ class RemoteExecutor(BaseExecutor):
         if hostname not in machine:
             cmd = f'{RSYNC} {bundle.code_file} {username}@{machine}:{bundle.code_file}'
             logger.info(f"Copying work to {worker} via {cmd}")
-            exec_utils.run_silently(cmd)
+            run_silently(cmd)
 
         # Do it.
         cmd = (f'{SSH} {bundle.username}@{bundle.machine} '
                f'"source remote-execution/bin/activate &&'
                f' /home/scott/lib/python_modules/remote_worker.py'
                f' --code_file {bundle.code_file} --result_file {bundle.result_file}"')
-        p = exec_utils.cmd_in_background(cmd, silent=True)
+        p = cmd_in_background(cmd, silent=True)
         bundle.pid = pid = p.pid
         logger.info(f"Running {cmd} in the background as process {pid}")
 
@@ -657,11 +656,11 @@ class RemoteExecutor(BaseExecutor):
                         f"Fetching results from {username}@{machine} via {cmd}"
                     )
                     try:
-                        exec_utils.run_silently(cmd)
+                        run_silently(cmd)
                     except subprocess.CalledProcessError:
                         pass
-                    exec_utils.run_silently(f'{SSH} {username}@{machine}'
-                                            f' "/bin/rm -f {code_file} {result_file}"')
+                    run_silently(f'{SSH} {username}@{machine}'
+                                 f' "/bin/rm -f {code_file} {result_file}"')
             bundle.end_ts = time.time()
             assert bundle.worker is not None
             self.status.record_release_worker_already_locked(
@@ -729,7 +728,8 @@ class RemoteExecutor(BaseExecutor):
         return result
 
     def create_original_bundle(self, pickle):
-        uuid = string_utils.generate_uuid(as_hex=True)
+        from string_utils import generate_uuid
+        uuid = generate_uuid(as_hex=True)
         code_file = f'/tmp/{uuid}.code.bin'
         result_file = f'/tmp/{uuid}.result.bin'