Salome HOME
[EDF27562] : Fix clustertest
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 8 Sep 2023 15:13:15 +0000 (17:13 +0200)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Mon, 2 Oct 2023 11:03:59 +0000 (13:03 +0200)
src/Basics/KernelBasis.cxx
src/Basics/KernelBasis.hxx
src/Basics/KernelBasis.i
src/Basics/libSALOMELog.cxx
src/Basics/libSALOMELog.hxx
src/Container/SALOME_ContainerManager.cxx
src/Container/ScriptsTemplate/SALOME_CM_REMOTE.py
src/Container/ScriptsTemplate/SALOME_CM_REMOTE_OLD.py
src/Container/ScriptsTemplate/script_parameters.py

index 921ac72c3250f87534c40664443000e6de827e35..f86b0026f1d0e29b6f4c8461f0e5eb354fb35fdd 100644 (file)
@@ -45,12 +45,30 @@ void setGUIMode(bool guiMode)
   GUI_MODE = guiMode;
 }
 
-std::string BASICS_EXPORT getIOROfEmbeddedNS()
+std::string getIOROfEmbeddedNS()
 {
   return IOR_OF_EMBEDDED_NS;
 }
 
-void BASICS_EXPORT setIOROfEmbeddedNS(const std::string& ior)
+void setIOROfEmbeddedNS(const std::string& ior)
 {
   IOR_OF_EMBEDDED_NS = ior;
 }
+
+#include <iostream>
+
+/*!
+ * Callable from Python in case if sys.stdout is not connected to tty
+ */
+void WriteInStdout(const std::string& msg)
+{
+  std::cout << msg << std::endl << std::flush;
+}
+
+/*!
+ * Callable from Python in case if sys.stdout is not connected to tty
+ */
+void WriteInStderr(const std::string& msg)
+{
+  std::cerr << msg << std::endl << std::flush;
+}
index 6e96c84e6c14c8104e44be3c968c1c6aee532521..2aa0499e532ba4a3ff3fe33fc90eaa241ac804bd 100644 (file)
@@ -30,3 +30,6 @@ void BASICS_EXPORT setGUIMode(bool guiMode);
 
 std::string BASICS_EXPORT getIOROfEmbeddedNS();
 void BASICS_EXPORT setIOROfEmbeddedNS(const std::string& ior);
+
+void BASICS_EXPORT WriteInStdout(const std::string& msg);
+void BASICS_EXPORT WriteInStderr(const std::string& msg);
index 7bbcf28d31c2dddf2db5e64f4f7b4f2d43cdfa7b..45908234b5f0ca5a09d6374209d7abe9c1858c30 100644 (file)
@@ -22,6 +22,7 @@
 %{
 #include "KernelBasis.hxx"
 #include "HeatMarcel.hxx"
+#include "libSALOMELog.hxx"
 using namespace SALOME;
 %}
 
@@ -40,6 +41,15 @@ void setIOROfEmbeddedNS(const std::string& ior);
 
 double GetTimeAdjustmentCst();
 
+bool VerbosityActivated();
+
+void SetVerbosityActivated(bool flag);
+
+void WriteInStdout(const std::string& msg);
+
+void WriteInStderr(const std::string& msg);
+
+
 %inline
 {
 PyObject *HeatMarcelSwig(double timeAjustment, unsigned int nbThreads = 0)
index fe0beeb2a355239ec7f13f1afedef8a2e98e9b92..b1d1332e61db1fc96f132ba8f6945b5b3feb0fb7 100644 (file)
 #include <string>
 #include <iostream>
 
+enum class VerbosityMode { undefined, nolog, withlog };
+
+static VerbosityMode isActivated = VerbosityMode::undefined;
+
 namespace SALOME
 {
 
@@ -43,7 +47,7 @@ namespace SALOME
 
   bool VerbosityActivated()
   {
-    auto isEnvVarSet = []() -> bool
+    auto isEnvVarSet = []() -> VerbosityMode
     {
       const char* envVar = std::getenv("SALOME_VERBOSE");
 
@@ -52,7 +56,7 @@ namespace SALOME
         try
         {
           const long long numValue = std::stoll(envVar);
-          return numValue > 0;
+          return numValue > 0?VerbosityMode::withlog:VerbosityMode::nolog;
         }
         catch(const std::exception& e)
         {
@@ -60,10 +64,16 @@ namespace SALOME
         }
       }
 
-      return false;
+      return VerbosityMode::nolog;
     };
 
-    static const bool isActivated = isEnvVarSet();
-    return isActivated;
+    if(isActivated == VerbosityMode::undefined)
+      isActivated = isEnvVarSet();
+    return isActivated == VerbosityMode::withlog;
+  }
+
+  void SetVerbosityActivated(bool flag)
+  {
+    isActivated = flag ? VerbosityMode::withlog:VerbosityMode::nolog;
   }
 }
index 93949515b382eac5203a0fd74722f9e895e1020d..7d4b70611e3c5147206c8182fcf78f5f3d54474c 100644 (file)
@@ -29,4 +29,5 @@
 namespace SALOME
 {
   bool BASICS_EXPORT VerbosityActivated();
+  void BASICS_EXPORT SetVerbosityActivated(bool);
 }
index 15bc6edec3f2bd24ee520a60455168b13cbba5f8..ffb6252f56a11688d73926559f33e589a6c8b5dc 100644 (file)
@@ -604,13 +604,22 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par
     MESSAGE("[GiveContainer] Try to launch a new container on " << resource_selected);
     // if a parallel container is launched in batch job, command is: "mpirun -np nbproc -machinefile nodesfile SALOME_MPIContainer"
     if( GetenvThreadSafe("LIBBATCH_NODEFILE") != NULL && params.isMPI )
+    {
       command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe, tmpFileName);
+      MESSAGE("[LaunchContainer] LIBBATCH_NODEFILE : \"" << command << "\"");
+    }
     // if a container is launched on localhost, command is "SALOME_Container" or "mpirun -np nbproc SALOME_MPIContainer"
     else if(hostname == Kernel_Utils::GetHostname())
+    {
       command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe, tmpFileName);
+      MESSAGE("[LaunchContainer] hostname local : \"" << command << "\"");
+    }
     // if a container is launched in remote mode, command is "ssh resource_selected SALOME_Container" or "ssh resource_selected mpirun -np nbproc SALOME_MPIContainer"
     else
+    {
       command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe);
+      MESSAGE("[LaunchContainer] remote : \"" << command << "\"");
+    }
 
     //redirect stdout and stderr in a file
 #ifdef WIN32
@@ -641,6 +650,7 @@ SALOME_ContainerManager::LaunchContainer(const Engines::ContainerParameters& par
     command += " > " + logFilename + " 2>&1";
     MakeTheCommandToBeLaunchedASync(command);
     
+    MESSAGE("[LaunchContainer] SYSTEM COMMAND that will be launched : \"" << command << "\"");
     // launch container with a system call
     status=SystemThreadSafe(command.c_str());
   }//end of critical of section
@@ -789,12 +799,14 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer(const std::string&
   std::string wdir = params.workingdir.in();
   if (!_isAppliSalomeDefined)
   {
+      MESSAGE("[BuildCommandToLaunchRemoteContainer] NO APPLI MODE : " << " Protocol :" << resInfo.Protocol << " hostname :" << resInfo.HostName << " username : " << resInfo.UserName << " appli : " << resInfo.AppliPath << " wdir : \"" << wdir << "\"");
       command = getCommandToRunRemoteProcessNoAppli(resInfo.Protocol, resInfo.HostName, 
                                                     resInfo.UserName, resInfo.AppliPath,
                                                     wdir);
   }
   else
   {
+    MESSAGE("[BuildCommandToLaunchRemoteContainer] WITH APPLI MODE : " << " Protocol :" << resInfo.Protocol << " hostname :" << resInfo.HostName << " username : " << resInfo.UserName << " appli : " << resInfo.AppliPath << " wdir : \"" << wdir << "\"");
     // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir
     //      SALOME_Container containerName -ORBInitRef NameService=IOR:01000..."
     //  or 
index c4a33b1960a673ef853cc5f684d48c1b61b9d7fa..f439a541d06656eb160e5d1bfa5b1733e3550849 100644 (file)
@@ -2,11 +2,8 @@ import sys
 
 class ScriptRemoteParameters:
     def __init__(self, args):
-        self.debug = False
-        if args[0] == "-d":
-            self.debug = True
-            args = args[1:]
-
+        import KernelBasis
+        self.debug = KernelBasis.VerbosityActivated()
         self.protocol = args[0]
         self.user = self._read_arg(args[1], "NULL")
         self.host = self._read_arg(args[2], "NULL")
@@ -45,8 +42,10 @@ class ScriptRemoteParameters:
 
 # ----------------------------------------------
 def command(args):
+    import KernelBasis
     options = ScriptRemoteParameters(args)
-    if options.debug: print(options)
+    if options.debug:
+        KernelBasis.WriteInStdout( str(options) )
 
     # build command depending on protocol
     cmd = []
@@ -102,7 +101,7 @@ def command(args):
 
         if options.workdir:
             cmd.append("-d " + options.workdir)
-            cmd.append("--")
+        cmd.append("--")
 
     # elif ignore other appli_mode value
 
index 9be7bd72e17f4f3e4505818c30a288b20773a395..a9808c17a0cd1ae62b0970d7404f598f430b614a 100644 (file)
@@ -2,11 +2,8 @@ import sys
 
 class ScriptRemoteParameters:
     def __init__(self, args):
-        self.debug = False
-        if args[0] == "-d":
-            self.debug = True
-            args = args[1:]
-
+        import KernelBasis
+        self.debug = KernelBasis.VerbosityActivated()
         self.protocol = args[0]
         self.user = self._read_arg(args[1], "NULL")
         self.host = self._read_arg(args[2], "NULL")
@@ -45,8 +42,10 @@ class ScriptRemoteParameters:
 
 # ----------------------------------------------
 def command(args):
+    import KernelBasis
     options = ScriptRemoteParameters(args)
-    if options.debug: print(options)
+    if options.debug:
+        KernelBasis.WriteInStdout( str(options) )
 
     # build command depending on protocol
     cmd = []
@@ -109,7 +108,7 @@ def command(args):
 
         if options.workdir:
             cmd.append("-d " + options.workdir)
-            cmd.append("--")
+        cmd.append("--")
 
     # elif ignore other appli_mode value
 
index 407f24a3ef6996c4205188a933267103569ac41a..ee1c6d3e7e4a6c82f8ed0e30666d3521bf2aa86a 100644 (file)
@@ -1,10 +1,7 @@
 class ScriptLocalParameters:
     def __init__(self, args):
-        self.debug = False
-        if args[0] == "-d":
-            self.debug = True
-            args = args[1:]
-
+        import KernelBasis
+        self.debug = KernelBasis.VerbosityActivated()
         self.nb_proc = self._read_arg(args[0], "NULL")
         self.workdir = self._read_arg(args[1], "NULL")
         self.isTmpDir = True if args[2] == "1" else False