From ea71c61ac9b9b119ef5f68d6531e98459595735e Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 5 Jun 2023 13:29:57 +0200 Subject: [PATCH] [EDF27816] : management of SALOME_FILE_BIG_OBJ_DIR with var expansion + addition of PyScriptNode.removeAllVarsInContext to reduce memory footprint --- idl/SALOME_PyNode.idl | 4 ++++ src/Basics/HeatMarcel.cxx | 5 ++--- src/Container/SALOME_PyNode.py | 13 ++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/idl/SALOME_PyNode.idl b/idl/SALOME_PyNode.idl index d4054d40a..7aaec4775 100644 --- a/idl/SALOME_PyNode.idl +++ b/idl/SALOME_PyNode.idl @@ -103,6 +103,10 @@ module Engines void assignVarInContext(in string varName, in pickledArgs value) raises (SALOME::SALOME_Exception); pickledArgs callMethodOnVarInContext(in string varName, in string methodName, in pickledArgs args) raises (SALOME::SALOME_Exception); + + listofstring listAllVarsInContext() raises (SALOME::SALOME_Exception); + + void removeAllVarsInContext() raises (SALOME::SALOME_Exception); } ; }; diff --git a/src/Basics/HeatMarcel.cxx b/src/Basics/HeatMarcel.cxx index a461a2288..f43b8229b 100644 --- a/src/Basics/HeatMarcel.cxx +++ b/src/Basics/HeatMarcel.cxx @@ -27,8 +27,7 @@ #include #include #include - -#include +#include template static void GetSlice(T start, T stop, const unsigned int sliceId, const unsigned int nbOfSlices, T& startSlice, T& stopSlice) @@ -59,7 +58,7 @@ static void SimulateOneCoreOfComputationNode(std::uint64_t start, std::uint64_t static long double SimulateOnAllCoresOfComputationNodeInternal(std::uint64_t nbTurn, unsigned int nbThreads) { - SIMPLE_MESSAGE( "Number of turn = 10**" << std::log10((double)nbTurn) ); + SIMPLE_MESSAGE( "Number of turn = " << std::scientific << std::setprecision(12) << (double)nbTurn ); std::vector< std::thread > threads(nbThreads); std::vector res(nbThreads); for(auto iCore = 0 ; iCore < nbThreads ; ++iCore) diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index 5e43428de..2e5f636e9 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -132,7 +132,7 @@ def GetBigObjectDirectory(): import os if SALOME_FILE_BIG_OBJ_DIR not in os.environ: raise RuntimeError("An object of size higher than limit detected and no directory specified to dump it in file !") - return os.environ[SALOME_FILE_BIG_OBJ_DIR] + return os.path.expandvars( os.path.expandvars( os.environ[SALOME_FILE_BIG_OBJ_DIR] ) ) def GetBigObjectFileName(): """ @@ -295,6 +295,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): data = argsInPy.data() _,kws=pickle.loads(data) for elt in kws: + # fetch real data if necessary kws[elt] = UnProxyObject( kws[elt] ) self.context.update(kws) except Exception: @@ -313,6 +314,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): argsout.append(self.context[arg]) ret = [ ] for arg in argsout: + # the proxy mecanism is catched here argPickle = SpoolPickleObject( arg ) retArg = SenderByte_i( self.poa,argPickle ) id_o = self.poa.activate_object(retArg) @@ -324,6 +326,15 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): l=traceback.format_exception(exc_typ,exc_val,exc_fr) raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode:Second %s, outargsname: %s" % (self.nodeName,outargsname),0)) + def listAllVarsInContext(self): + import re + pat = re.compile("^__([a-z]+)__$") + return [elt for elt in self.context if not pat.match(elt)] + + def removeAllVarsInContext(self): + for elt in self.listAllVarsInContext(): + del self.context[elt] + def getValueOfVarInContext(self,varName): try: return pickle.dumps(self.context[varName],-1) -- 2.39.2