From 7ec3a50faee168e01b6e0447f0630960bcc4c700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 26 Oct 2024 14:09:14 +0200 Subject: [PATCH] Move get_command_path() to separate module --- executorlib/shared/cache.py | 2 +- executorlib/shared/command.py | 14 ++++++++++++++ executorlib/shared/executor.py | 15 +-------------- 3 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 executorlib/shared/command.py diff --git a/executorlib/shared/cache.py b/executorlib/shared/cache.py index a2b5975b..9313a3a1 100644 --- a/executorlib/shared/cache.py +++ b/executorlib/shared/cache.py @@ -10,7 +10,7 @@ import cloudpickle -from executorlib.shared.executor import get_command_path +from executorlib.shared.command import get_command_path from executorlib.shared.hdf import dump, get_output, load diff --git a/executorlib/shared/command.py b/executorlib/shared/command.py new file mode 100644 index 00000000..8dfa8e83 --- /dev/null +++ b/executorlib/shared/command.py @@ -0,0 +1,14 @@ +import os + + +def get_command_path(executable: str) -> str: + """ + Get path of the backend executable script + + Args: + executable (str): Name of the backend executable script, either mpiexec.py or serial.py + + Returns: + str: absolute path to the executable script + """ + return os.path.abspath(os.path.join(__file__, "..", "..", "backend", executable)) diff --git a/executorlib/shared/executor.py b/executorlib/shared/executor.py index b49c55f0..24c0c613 100644 --- a/executorlib/shared/executor.py +++ b/executorlib/shared/executor.py @@ -1,6 +1,5 @@ import importlib.util import inspect -import os import queue import sys from concurrent.futures import ( @@ -14,6 +13,7 @@ import cloudpickle +from executorlib.shared.command import get_command_path from executorlib.shared.communication import interface_bootup from executorlib.shared.inputcheck import ( check_resource_dict, @@ -465,19 +465,6 @@ def execute_tasks_with_dependencies( sleep(refresh_rate) -def get_command_path(executable: str) -> str: - """ - Get path of the backend executable script - - Args: - executable (str): Name of the backend executable script, either mpiexec.py or serial.py - - Returns: - str: absolute path to the executable script - """ - return os.path.abspath(os.path.join(__file__, "..", "..", "backend", executable)) - - def _get_backend_path( cores: int, ) -> list: