From f55a078ec2c3699e7f7ccc9dc6bdb7bcef38b7b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jan=C3=9Fen?= Date: Sat, 11 Nov 2023 09:56:27 +0100 Subject: [PATCH] Fix module index --- .ci_support/environment-docs.yml | 3 ++- pympipool/__init__.py | 12 +++++------- pympipool/slurm/executor.py | 10 +--------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.ci_support/environment-docs.yml b/.ci_support/environment-docs.yml index a6ab251e..1a112178 100644 --- a/.ci_support/environment-docs.yml +++ b/.ci_support/environment-docs.yml @@ -9,4 +9,5 @@ dependencies: - cloudpickle - mpi4py - tqdm - - pyzmq \ No newline at end of file + - pyzmq + - flux-core \ No newline at end of file diff --git a/pympipool/__init__.py b/pympipool/__init__.py index fff44455..9753846b 100644 --- a/pympipool/__init__.py +++ b/pympipool/__init__.py @@ -1,6 +1,9 @@ import os +import shutil from ._version import get_versions from pympipool.mpi.executor import PyMPIExecutor +from pympipool.shared.interface import SLURM_COMMAND +from pympipool.slurm.executor import PySlurmExecutor try: # The PyFluxExecutor requires flux-core to be installed. from pympipool.flux.executor import PyFluxExecutor @@ -10,13 +13,8 @@ flux_installed = False pass -try: # The PySlurmExecutor requires the srun command to be available. - from pympipool.slurm.executor import PySlurmExecutor - - slurm_installed = True -except ImportError: - slurm_installed = False - pass +# The PySlurmExecutor requires the srun command to be available. +slurm_installed = shutil.which(SLURM_COMMAND) is not None __version__ = get_versions()["version"] diff --git a/pympipool/slurm/executor.py b/pympipool/slurm/executor.py index 2e4e5765..96b349a3 100644 --- a/pympipool/slurm/executor.py +++ b/pympipool/slurm/executor.py @@ -1,21 +1,13 @@ -import shutil -import subprocess - - from pympipool.shared.executorbase import ( cloudpickle_register, execute_parallel_tasks, ExecutorBase, executor_broker, ) -from pympipool.shared.interface import SrunInterface, SLURM_COMMAND +from pympipool.shared.interface import SrunInterface from pympipool.shared.thread import RaisingThread -if shutil.which(SLURM_COMMAND) is None: - raise ImportError("SLURM command " + SLURM_COMMAND + " not found.") - - class PySlurmExecutor(ExecutorBase): """ The pympipool.slurm.PySlurmExecutor leverages the srun command to distribute python tasks within a SLURM queuing