From 607bbdaf1dcc711bf98d9e8923eeab055ac9a4b1 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Thu, 1 Oct 2020 10:31:26 +0200 Subject: [PATCH] Rename noyacs to slurm. --- src/pydefx/CMakeLists.txt | 6 +++--- src/pydefx/__init__.py | 2 +- src/pydefx/multijob/mainjob.py | 2 +- src/pydefx/{noyacs => slurm}/CMakeLists.txt | 2 +- src/pydefx/{noyacs => slurm}/executor.py | 7 +++++-- src/pydefx/{noyacs => slurm}/mainjob.py | 2 +- src/pydefx/{noyacs => slurm}/pointeval.py | 0 src/pydefx/{noyacsbuilder.py => slurmbuilder.py} | 4 ++-- src/pydefx/{noyacsstudy.py => slurmstudy.py} | 8 +++++--- 9 files changed, 19 insertions(+), 14 deletions(-) rename src/pydefx/{noyacs => slurm}/CMakeLists.txt (87%) rename src/pydefx/{noyacs => slurm}/executor.py (87%) rename src/pydefx/{noyacs => slurm}/mainjob.py (97%) rename src/pydefx/{noyacs => slurm}/pointeval.py (100%) rename src/pydefx/{noyacsbuilder.py => slurmbuilder.py} (98%) rename src/pydefx/{noyacsstudy.py => slurmstudy.py} (92%) diff --git a/src/pydefx/CMakeLists.txt b/src/pydefx/CMakeLists.txt index e228afa..8f16098 100644 --- a/src/pydefx/CMakeLists.txt +++ b/src/pydefx/CMakeLists.txt @@ -31,11 +31,11 @@ SET(SCRIPTS salome_proxy.py multijobbuilder.py multijobstudy.py - noyacsbuilder.py - noyacsstudy.py + slurmbuilder.py + slurmstudy.py ) INSTALL(FILES ${SCRIPTS} DESTINATION ${SALOME_INSTALL_PYTHON}/pydefx) ADD_SUBDIRECTORY(schemas) ADD_SUBDIRECTORY(multijob) -ADD_SUBDIRECTORY(noyacs) +ADD_SUBDIRECTORY(slurm) diff --git a/src/pydefx/__init__.py b/src/pydefx/__init__.py index a30a453..d59cde8 100644 --- a/src/pydefx/__init__.py +++ b/src/pydefx/__init__.py @@ -24,4 +24,4 @@ from .defaultschemabuilder import DefaultSchemaBuilder from .salome_proxy import forceSalomeServers, forceNoSalomeServers from .multijobstudy import MultiJobStudy -from .noyacsstudy import NoYacsStudy +from .slurmstudy import SlurmStudy diff --git a/src/pydefx/multijob/mainjob.py b/src/pydefx/multijob/mainjob.py index 2ff8bea..b9cfe3f 100644 --- a/src/pydefx/multijob/mainjob.py +++ b/src/pydefx/multijob/mainjob.py @@ -1,7 +1,7 @@ #! /usr/bin/env python3 import json import importlib -from multiprocessing.dummy import Pool +from multiprocessing import Pool import traceback class StartJob: diff --git a/src/pydefx/noyacs/CMakeLists.txt b/src/pydefx/slurm/CMakeLists.txt similarity index 87% rename from src/pydefx/noyacs/CMakeLists.txt rename to src/pydefx/slurm/CMakeLists.txt index ccb015a..78b99a1 100644 --- a/src/pydefx/noyacs/CMakeLists.txt +++ b/src/pydefx/slurm/CMakeLists.txt @@ -4,4 +4,4 @@ SET(SCHEMA_FILES pointeval.py ) -INSTALL(FILES ${SCHEMA_FILES} DESTINATION ${SALOME_INSTALL_PYTHON}/pydefx/noyacs) +INSTALL(FILES ${SCHEMA_FILES} DESTINATION ${SALOME_INSTALL_PYTHON}/pydefx/slurm) diff --git a/src/pydefx/noyacs/executor.py b/src/pydefx/slurm/executor.py similarity index 87% rename from src/pydefx/noyacs/executor.py rename to src/pydefx/slurm/executor.py index d7a3014..a779c92 100644 --- a/src/pydefx/noyacs/executor.py +++ b/src/pydefx/slurm/executor.py @@ -63,9 +63,12 @@ class JobExecutor: Create, launch and wait for the end of the job. """ # srun + ntasks = self.config["tasksPerEval"] pointeval = os.path.join(os.getcwd(), "pointeval.py") - command = "srun --ntasks=1 --nodes=1 --chdir={} {} ".format(context.local_dir, - pointeval) + command = "srun --ntasks={} --nodes=1 --chdir={} {} ".format( + str(ntasks), + context.local_dir, + pointeval) return_code = subprocess.call(command, shell=True) def getResult(self, context): diff --git a/src/pydefx/noyacs/mainjob.py b/src/pydefx/slurm/mainjob.py similarity index 97% rename from src/pydefx/noyacs/mainjob.py rename to src/pydefx/slurm/mainjob.py index 2ff8bea..b9cfe3f 100644 --- a/src/pydefx/noyacs/mainjob.py +++ b/src/pydefx/slurm/mainjob.py @@ -1,7 +1,7 @@ #! /usr/bin/env python3 import json import importlib -from multiprocessing.dummy import Pool +from multiprocessing import Pool import traceback class StartJob: diff --git a/src/pydefx/noyacs/pointeval.py b/src/pydefx/slurm/pointeval.py similarity index 100% rename from src/pydefx/noyacs/pointeval.py rename to src/pydefx/slurm/pointeval.py diff --git a/src/pydefx/noyacsbuilder.py b/src/pydefx/slurmbuilder.py similarity index 98% rename from src/pydefx/noyacsbuilder.py rename to src/pydefx/slurmbuilder.py index 81ffe65..3f8eae2 100644 --- a/src/pydefx/noyacsbuilder.py +++ b/src/pydefx/slurmbuilder.py @@ -21,11 +21,11 @@ import inspect import pathlib import os -class NoYacsBuilder: +class SlurmBuilder: def __init__(self, executor = None, pointEval = None, mainJob = None): filename = inspect.getframeinfo(inspect.currentframe()).filename install_root_directory = pathlib.Path(filename).resolve().parent - install_files_directory = os.path.join(install_root_directory, "noyacs") + install_files_directory = os.path.join(install_root_directory, "slurm") if executor is None: executor = os.path.join(install_files_directory, "executor.py") diff --git a/src/pydefx/noyacsstudy.py b/src/pydefx/slurmstudy.py similarity index 92% rename from src/pydefx/noyacsstudy.py rename to src/pydefx/slurmstudy.py index 91e1579..8be211b 100644 --- a/src/pydefx/noyacsstudy.py +++ b/src/pydefx/slurmstudy.py @@ -21,14 +21,14 @@ import copy import os import json from . import pystudy -from . import noyacsbuilder +from . import slurmbuilder from . import salome_proxy -class NoYacsStudy(pystudy.PyStudy): +class SlurmStudy(pystudy.PyStudy): def __init__(self, sampleManager=None, schemaBuilder=None): if schemaBuilder is None: - schemaBuilder = noyacsbuilder.NoYacsBuilder() + schemaBuilder = slurmbuilder.SlurmBuilder() super().__init__(sampleManager, schemaBuilder) def createNewJob(self, script, sample, params): @@ -56,6 +56,8 @@ class NoYacsStudy(pystudy.PyStudy): dicconfig["studymodule"] = "idefixstudy" dicconfig["sampleIterator"] = self.sampleManager.getModuleName() dicconfig["plugin"] = self.schemaBuilder.getPluginName() + nbproc = self.params.salome_parameters.resource_required.nb_proc + dicconfig["tasksPerEval"] = nbproc // self.params.nb_branches with open(configpath, "w") as f: json.dump(dicconfig, f, indent=2) studypath = os.path.join(result_directory, "idefixstudy.py") -- 2.39.2