X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=executors.py;h=2f4cf8314fdb07c536c75999fa40ecd83781cb05;hb=0e451d3b3bf899b3d9ac0c38e3c3cd9d9be170ba;hp=2b2f0252ce326fd34800080735f5324f91bfc315;hpb=3bc4daf1edc121cd633429187392227f2fa61885;p=python_utils.git diff --git a/executors.py b/executors.py index 2b2f025..2f4cf83 100644 --- a/executors.py +++ b/executors.py @@ -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'