From 2217a6a1bb8dcd5a5cb96c22e190725c6c77f34c Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 7 Jan 2019 08:09:32 +0100 Subject: [PATCH] Cleanup --- src/CMakeLists.txt | 2 +- src/Laucher_SWIG/Launcher.i | 58 ------- .../CMakeLists.txt | 10 +- src/Launcher_SWIG/Launcher.i | 152 ++++++++++++++++++ 4 files changed, 161 insertions(+), 61 deletions(-) delete mode 100644 src/Laucher_SWIG/Launcher.i rename src/{Laucher_SWIG => Launcher_SWIG}/CMakeLists.txt (90%) create mode 100644 src/Launcher_SWIG/Launcher.i diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 25b7dc6e8..832150e89 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,7 +41,7 @@ SET(SUBDIR_CORBA SALOMESDS TestContainer Launcher - Laucher_SWIG + Launcher_SWIG LifeCycleCORBA LifeCycleCORBA_SWIG SALOMEDSClient diff --git a/src/Laucher_SWIG/Launcher.i b/src/Laucher_SWIG/Launcher.i deleted file mode 100644 index bb85fbbcd..000000000 --- a/src/Laucher_SWIG/Launcher.i +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2019 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%module pylauncher - -%{ -#include "SALOME_ResourcesCatalog_Parser.hxx" -#include "Launcher_Job.hxx" -%} - -class ParserResourcesType -{ -public: - ParserResourcesType(); - ~ParserResourcesType(); - std::string getAccessProtocolTypeStr() const; - std::string getResourceTypeStr() const; - std::string getBatchTypeStr() const; - std::string getMpiImplTypeStr() const; - std::string getClusterInternalProtocolStr() const; - std::string getCanLaunchBatchJobsStr() const; - std::string getCanRunContainersStr() const; - - void setAccessProtocolTypeStr(const std::string & protocolTypeStr); - void setResourceTypeStr(const std::string & resourceTypeStr); - void setBatchTypeStr(const std::string & batchTypeStr); - void setMpiImplTypeStr(const std::string & mpiImplTypeStr); - void setClusterInternalProtocolStr(const std::string & internalProtocolTypeStr); - void setCanLaunchBatchJobsStr(const std::string & canLaunchBatchJobsStr); - void setCanRunContainersStr(const std::string & canRunContainersStr); -}; - -namespace Launcher -{ - class Job - { - public: - Job(); - virtual ~Job(); - virtual void update_job() = 0; - }; -} diff --git a/src/Laucher_SWIG/CMakeLists.txt b/src/Launcher_SWIG/CMakeLists.txt similarity index 90% rename from src/Laucher_SWIG/CMakeLists.txt rename to src/Launcher_SWIG/CMakeLists.txt index 096e83eec..e758b78d9 100644 --- a/src/Laucher_SWIG/CMakeLists.txt +++ b/src/Launcher_SWIG/CMakeLists.txt @@ -21,18 +21,24 @@ INCLUDE(${SWIG_USE_FILE}) ADD_DEFINITIONS(${PYTHON_DEFINITIONS}) +SET(Launcher_target_name pylauncher) + +IF(SALOME_USE_LIBBATCH) + ADD_DEFINITIONS(-DWITH_LIBBATCH) + SET(SWIG_MODULE_${Launcher_target_name}_EXTRA_FLAGS "-DWITH_LIBBATCH") +ENDIF(SALOME_USE_LIBBATCH) + SET_SOURCE_FILES_PROPERTIES(Launcher.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(Launcher.i PROPERTIES SWIG_FLAGS "-py3") INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} + ${LIBBATCH_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../ResourcesManager ${CMAKE_CURRENT_SOURCE_DIR}/../Launcher ) -SET(Launcher_target_name pylauncher) - SWIG_ADD_LIBRARY(${Launcher_target_name} LANGUAGE python SOURCES Launcher.i) SWIG_LINK_LIBRARIES(${Launcher_target_name} ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} Launcher) diff --git a/src/Launcher_SWIG/Launcher.i b/src/Launcher_SWIG/Launcher.i new file mode 100644 index 000000000..e66ad8a6a --- /dev/null +++ b/src/Launcher_SWIG/Launcher.i @@ -0,0 +1,152 @@ +// Copyright (C) 2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +%module pylauncher + +%{ +#include "SALOME_ResourcesCatalog_Parser.hxx" +#include "Launcher_Job.hxx" +#include "Launcher_Job_SALOME.hxx" +#include "Launcher_Job_YACSFile.hxx" +%} + +class ParserResourcesType +{ +public: + ParserResourcesType(); + ~ParserResourcesType(); + std::string getAccessProtocolTypeStr() const; + std::string getResourceTypeStr() const; + std::string getBatchTypeStr() const; + std::string getMpiImplTypeStr() const; + std::string getClusterInternalProtocolStr() const; + std::string getCanLaunchBatchJobsStr() const; + std::string getCanRunContainersStr() const; + + void setAccessProtocolTypeStr(const std::string & protocolTypeStr); + void setResourceTypeStr(const std::string & resourceTypeStr); + void setBatchTypeStr(const std::string & batchTypeStr); + void setMpiImplTypeStr(const std::string & mpiImplTypeStr); + void setClusterInternalProtocolStr(const std::string & internalProtocolTypeStr); + void setCanLaunchBatchJobsStr(const std::string & canLaunchBatchJobsStr); + void setCanRunContainersStr(const std::string & canRunContainersStr); +}; + +namespace Launcher +{ + class Job + { + public: + Job(); + virtual ~Job(); + void setState(const std::string & state); + std::string getState() const; + std::string getAssignedHostnames(); + void setNumber(const int & number); + int getNumber(); + virtual void setResourceDefinition(const ParserResourcesType & resource_definition); + ParserResourcesType getResourceDefinition() const; + // Common parameters + void setJobName(const std::string & job_name); + virtual void setJobFile(const std::string & job_file); + void setPreCommand(const std::string & preCommand); + void setWorkDirectory(const std::string & work_directory); + void setLocalDirectory(const std::string & local_directory); + void setResultDirectory(const std::string & result_directory); + void add_in_file(const std::string & file); + void add_out_file(const std::string & file); + void setMaximumDuration(const std::string & maximum_duration); + void setResourceRequiredParams(const resourceParams & resource_required_params); + void setQueue(const std::string & queue); + void setPartition(const std::string & partition); + void setEnvFile(const std::string & env_file); + void setExclusive(bool exclusive); + void setExclusiveStr(const std::string & exclusiveStr); + void setMemPerCpu(unsigned long mem_per_cpu); + void setWCKey(const std::string & wckey); + void setExtraParams(const std::string & extra_params); + void setReference(const std::string & reference); + // For COORM + void setLauncherFile(const std::string & launcher_file); + void setLauncherArgs(const std::string & launcher_args); + + std::string getJobName() const; + std::string getJobFile() const; + std::string getPreCommand() const; + std::string getWorkDirectory() const; + std::string getLocalDirectory() const; + std::string getResultDirectory() const; + const std::list & get_in_files() const; + const std::list & get_out_files() const; + std::string getMaximumDuration() const; + resourceParams getResourceRequiredParams() const; + std::string getQueue() const; + std::string getPartition() const; + std::string getEnvFile() const; + std::string getJobType() const; + bool getExclusive() const; + std::string getExclusiveStr() const; + unsigned long getMemPerCpu() const; + std::string getWCKey() const; + std::string getExtraParams() const; + std::string getReference() const; + std::string getLauncherFile() const; + std::string getLauncherArgs() const; + std::string updateJobState(); + + void addSpecificParameter(const std::string & name, const std::string & value); + const std::map & getSpecificParameters() const; + virtual void checkSpecificParameters(); + + // Checks + void checkMaximumDuration(const std::string & maximum_duration); + void checkResourceRequiredParams(const resourceParams & resource_required_params); + + // Helps + long convertMaximumDuration(const std::string & maximum_duration); + std::string getLaunchDate() const; + + void stopJob(); + void removeJob(); + virtual void update_job() = 0; + }; + + class Job_SALOME : public Job + { + private: + Job_SALOME(); + public: + virtual ~Job_SALOME(); + virtual void setResourceDefinition(const ParserResourcesType & resource_definition); + virtual void update_job(); +#ifdef WITH_LIBBATCH + public: + std::string buildSalomeScript(Batch::Parametre params); +#endif + }; + + class Job_YACSFile : public Job_SALOME + { + public: + Job_YACSFile(); + virtual ~Job_YACSFile(); + virtual void setJobFile(const std::string & job_file); + virtual void checkSpecificParameters(); + }; +} -- 2.39.2