YACSEvalSeqAny.hxx
YACSEvalResource.hxx
YACSEvalSession.hxx
+ YACSEvalSessionInternal.hxx
YACSEvalObserver.hxx
YACSEvalExecParams.hxx
)
YACSEvalSeqAny.cxx
YACSEvalResource.cxx
YACSEvalSession.cxx
+ YACSEvalSessionInternal.cxx
YACSEvalObserver.cxx
)
{
if(_remoteWorkingDir.empty())
throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : remote work dir is not set !");
+ if(_localWorkingDir.empty())
+ throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : local work dir is not set !");
if(_wcKey.empty())
throw YACS::Exception("YACSEvalParamsForCluster::checkConsistency : WC key is not set !");
if(_nbOfProcs==0)
void setExclusiveness(bool newStatus);
std::string getRemoteWorkingDir() const { return _remoteWorkingDir; }
void setRemoteWorkingDir(const std::string& remoteWorkingDir) { _remoteWorkingDir=remoteWorkingDir; }
+ std::string getLocalWorkingDir() const { return _localWorkingDir; }
+ void setLocalWorkingDir(const std::string& localWorkingDir) { _localWorkingDir=localWorkingDir; }
std::string getWCKey() const { return _wcKey; }
void setWCKey(const std::string& wcKey) { _wcKey=wcKey; }
unsigned int getNbProcs() const { return _nbOfProcs; }
void setNbProcs(unsigned int nbProcs) { _nbOfProcs=nbProcs; }
+ void setMaxDuration(const std::string& maxDuration) { _maxDuration=maxDuration; }
+ std::string getMaxDuration() const { return _maxDuration; }
void checkConsistency() const;
private:
bool _exclusiveness;
std::string _remoteWorkingDir;
+ std::string _localWorkingDir;
std::string _wcKey;
+ std::string _maxDuration;
unsigned int _nbOfProcs;
};
YACSEVALYFX_EXPORT unsigned int getNumberOfProcsDeclared() const;
YACSEVALYFX_EXPORT void checkOKForRun() const;
YACSEVALYFX_EXPORT YACSEvalParamsForCluster& getAddParamsForCluster() { return _paramsInCaseOfCluster; }
+ YACSEVALYFX_EXPORT const YACSEvalParamsForCluster& getAddParamsForCluster() const { return _paramsInCaseOfCluster; }
void apply();
YACSEVALYFX_EXPORT ~YACSEvalListOfResources();
public:
// Author : Anthony Geay (EDF R&D)
#include "YACSEvalSession.hxx"
+#include "YACSEvalSessionInternal.hxx"
+
#include "Exception.hxx"
#include <Python.h>
const char YACSEvalSession::CORBA_CONFIG_ENV_VAR_NAME[]="OMNIORB_CONFIG";
-YACSEvalSession::YACSEvalSession():_isLaunched(false),_port(-1),_salomeInstanceModule(0),_salomeInstance(0)
+YACSEvalSession::YACSEvalSession():_isLaunched(false),_port(-1),_salomeInstanceModule(0),_salomeInstance(0),_internal(new YACSEvalSessionInternal)
{
if(!Py_IsInitialized())
Py_Initialize();
YACSEvalSession::~YACSEvalSession()
{
+ delete _internal;
if(isLaunched())
{
PyObject *terminateSession(PyObject_GetAttrString(_salomeInstance,const_cast<char *>("stop")));//new
class YACSEvalSession
{
+public:
+ class YACSEvalSessionInternal;
public:
YACSEVALYFX_EXPORT YACSEvalSession();
YACSEVALYFX_EXPORT ~YACSEvalSession();
YACSEVALYFX_EXPORT void checkLaunched() const;
YACSEVALYFX_EXPORT int getPort() const;
YACSEVALYFX_EXPORT std::string getCorbaConfigFileName() const;
+public:
+ YACSEvalSessionInternal *getInternal() { checkLaunched(); return _internal; }
private:
static std::string GetPathToAdd();
public:
std::string _corbaConfigFileName;
PyObject *_salomeInstanceModule;
PyObject *_salomeInstance;
+ YACSEvalSessionInternal *_internal;
};
#endif
--- /dev/null
+// Copyright (C) 2012-2015 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
+//
+// Author : Anthony Geay (EDF R&D)
+
+#include "YACSEvalSessionInternal.hxx"
+#include "YACSEvalSession.hxx"
+
+#include "PyStdout.hxx"
+#include "AutoGIL.hxx"
+#include "Exception.hxx"
+
+YACSEvalSession::YACSEvalSessionInternal::YACSEvalSessionInternal():_orb(CORBA::ORB::_nil()),_sl(Engines::SalomeLauncher::_nil())
+{
+}
+
+void YACSEvalSession::YACSEvalSessionInternal::checkSalomeLauncher()
+{
+ if(CORBA::is_nil(_sl))
+ throw YACS::Exception("YACSEvalSessionInternal::checkSalomeLauncher : salome launcher is null !");
+}
+
+Engines::SalomeLauncher_var YACSEvalSession::YACSEvalSessionInternal::goFetchingSalomeLauncherInNS()
+{
+ if(!CORBA::is_nil(_sl))
+ return _sl;
+ int argc(0);
+ _orb=CORBA::ORB_init(argc,0);
+ if(CORBA::is_nil(_orb))
+ throw YACS::Exception("YACSEvalSessionInternal contrctor : ORB is null !");
+ //
+ const char methName[]="goFetchingSalomeLauncherInNS";
+ const char fetchPyCmd[]="import salome,CORBA\nsalome.salome_init()\nsl=salome.naming_service.Resolve(\"/SalomeLauncher\")\nif not CORBA.is_nil(sl):\n return salome.orb.object_to_string(sl)\nelse:\n raise Exception(\"Impossible to locate salome launcher !\")";
+ YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(methName,fetchPyCmd));
+ YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
+ std::string ior(PyString_AsString(val));
+ CORBA::Object_var obj(string_to_object(ior));
+ if(CORBA::is_nil(obj))
+ throw YACS::Exception("goFetchingSalomeLauncherInNS : fetched ior is NIL !");
+ _sl=Engines::SalomeLauncher::_narrow(obj);
+ checkSalomeLauncher();
+ return _sl;
+}
+
+Engines::SalomeLauncher_var YACSEvalSession::YACSEvalSessionInternal::getNotNullSL()
+{
+ checkSalomeLauncher();
+ return _sl;
+}
--- /dev/null
+// Copyright (C) 2012-2015 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
+//
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef __YACSEVALSESSIONINTERNAL_HXX__
+#define __YACSEVALSESSIONINTERNAL_HXX__
+
+#include "YACSEvalSession.hxx"
+
+#include "SALOMEconfig.h"
+#include CORBA_CLIENT_HEADER(SALOME_Launcher)
+#include "omniORB4/CORBA.h"
+
+#include <string>
+
+class YACSEvalSession::YACSEvalSessionInternal
+{
+public:
+ YACSEvalSessionInternal();
+ CORBA::Object_var string_to_object(const std::string& ior) { return _orb->string_to_object(ior.c_str()); }
+ Engines::SalomeLauncher_var goFetchingSalomeLauncherInNS();
+ Engines::SalomeLauncher_var getNotNullSL();
+private:
+ void checkSalomeLauncher();
+private:
+ CORBA::ORB_var _orb;
+ Engines::SalomeLauncher_var _sl;
+};
+
+#endif
// throw YACS::Exception("YACSEvalYFX::run : not implemented yet for non interactive !");
rss->apply();
nbOfBranches=_pattern->assignNbOfBranches();
- return _pattern->go(_params.getStopASAPAfterErrorStatus());
+ return _pattern->go(_params.getStopASAPAfterErrorStatus(),session);
}
void YACSEvalYFX::registerObserver(YACSEvalObserver *observer)
#include "YACSEvalYFXPattern.hxx"
#include "YACSEvalResource.hxx"
#include "YACSEvalSeqAny.hxx"
+#include "YACSEvalSession.hxx"
#include "YACSEvalObserver.hxx"
+#include "YACSEvalSessionInternal.hxx"
#include "YACSEvalAutoPtr.hxx"
#include "ElementaryNode.hxx"
obs->notifyNumberOfSamplesToEval(getBoss(),_FEInGeneratedGraph->getNbOfElementsToBeProcessed());
}
-bool YACSEvalYFXRunOnlyPattern::go(bool stopASAP) const
+bool YACSEvalYFXRunOnlyPattern::go(bool stopASAP, YACSEvalSession *session) const
{
emitStart();
if(getResourcesInternal()->isInteractive())
}
else
{
- char EFXGenFileName[]="EFXGenFileName";
- char EFXGenContent[]="import getpass,datetime,os\nn=datetime.datetime.now()\nreturn os.path.join(os.path.sep,\"tmp\",\"EvalYFX_%s_%s_%s.xml\"%(getpass.getuser(),n.strftime(\"%d%b%y\"),n.strftime(\"%H%M%S\")))";
+ const char EFXGenFileName[]="EFXGenFileName";
+ const char EFXGenContent[]="import getpass,datetime,os\nn=datetime.datetime.now()\nreturn os.path.join(os.path.sep,\"tmp\",\"EvalYFX_%s_%s_%s.xml\"%(getpass.getuser(),n.strftime(\"%d%b%y\"),n.strftime(\"%H%M%S\")))";
+ const char EFXGenContent2[]="import getpass,datetime\nn=datetime.datetime.now()\nreturn \"EvalYFX_%s_%s_%s\"%(getpass.getuser(),n.strftime(\"%d%b%y\"),n.strftime(\"%H%M%S\"))";
//
YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent));
YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
- std::string fn(PyString_AsString(val));
- getUndergroundGeneratedGraph()->saveSchema(fn);
+ std::string locSchemaFile(PyString_AsString(val));
+ getUndergroundGeneratedGraph()->saveSchema(locSchemaFile);
+ func=YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent2);
+ val=YACS::ENGINE::evalFuncPyWithNoParams(func);
+ std::string jobName(PyString_AsString(val));
+ YACSEvalListOfResources *rss(getResourcesInternal());
+ const YACSEvalParamsForCluster& cli(rss->getAddParamsForCluster());
+ std::vector<std::string> machines(rss->getAllChosenMachines());
+ if(machines.size()!=1)
+ throw YACS::Exception("YACSEvalYFXRunOnlyPattern::go : internal error ! In batch mode and not exactly one machine !");
+ Engines::SalomeLauncher_var sl(session->getInternal()->goFetchingSalomeLauncherInNS());
+ Engines::ResourceParameters rr;
+ rr.name=CORBA::string_dup(machines[0].c_str());
+ rr.hostname=CORBA::string_dup("");
+ rr.can_launch_batch_jobs=true;
+ rr.can_run_containers=true;
+ rr.OS=CORBA::string_dup("Linux");
+ rr.componentList.length(0);
+ rr.nb_proc=rss->getNumberOfProcsDeclared();// <- important
+ rr.mem_mb=1024;
+ rr.cpu_clock=1000;
+ rr.nb_node=1;// useless only nb_proc used.
+ rr.nb_proc_per_node=1;// useless only nb_proc used.
+ rr.policy=CORBA::string_dup("cycl");
+ rr.resList.length(0);
+ Engines::JobParameters jp;
+ jp.job_name=CORBA::string_dup(jobName.c_str());
+ jp.job_type=CORBA::string_dup("yacs_file");
+ jp.job_file=CORBA::string_dup(locSchemaFile.c_str());
+ jp.env_file=CORBA::string_dup("");
+ jp.in_files.length();
+ jp.out_files.length();
+ jp.work_directory=CORBA::string_dup(cli.getRemoteWorkingDir().c_str());
+ jp.local_directory=CORBA::string_dup(cli.getLocalWorkingDir().c_str());
+ jp.result_directory=CORBA::string_dup(cli.getLocalWorkingDir().c_str());
+ jp.maximum_duration=CORBA::string_dup(cli.getMaxDuration().c_str());
+ jp.resource_required=rr;
+ jp.queue=CORBA::string_dup("");
+ jp.exclusive=false;
+ jp.mem_per_cpu=rr.mem_mb;
+ jp.wckey=CORBA::string_dup(cli.getWCKey().c_str());
+ jp.extra_params=CORBA::string_dup("");
+ jp.specific_parameters.length(0);
+ jp.launcher_file=CORBA::string_dup("");
+ jp.launcher_args=CORBA::string_dup("");
+ CORBA::Long jobid(sl->createJob(jp));
+ sl->launchJob(jobid);
+ std::cerr << "*** " << jobName << " -> " << jobid << std::endl;
return false;
}
}
}
class YACSEvalYFX;
+class YACSEvalSession;
class YACSEvalObserver;
class YACSEvalListOfResources;
class ResourcesManager_cpp;
virtual std::string getStatusOfRunStr() const = 0;
virtual std::vector<YACSEvalSeqAny *> getResults() const = 0;
virtual std::vector<YACSEvalSeqAny *> getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const = 0;
- virtual bool go(bool stopASAP) const = 0;
+ virtual bool go(bool stopASAP, YACSEvalSession *session) const = 0;
public:
static const char DFT_PROC_NAME[];
protected:
std::string getStatusOfRunStr() const;
std::vector<YACSEvalSeqAny *> getResults() const;
std::vector<YACSEvalSeqAny *> getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const;
- bool go(bool stopASAP) const;
+ bool go(bool stopASAP, YACSEvalSession *session) const;
//
YACS::ENGINE::ForEachLoop *getUndergroundForEach() const { return _FEInGeneratedGraph; }
static bool IsMatching(YACS::ENGINE::Proc *scheme, YACS::ENGINE::ComposedNode *& runNode);
void setExclusiveness(bool newStatus);
std::string getRemoteWorkingDir();
void setRemoteWorkingDir(const std::string& remoteWorkingDir);
+ std::string getLocalWorkingDir();
+ void setLocalWorkingDir(const std::string& localWorkingDir);
std::string getWCKey() const;
void setWCKey(const std::string& wcKey);
unsigned int getNbProcs() const;
void setNbProcs(unsigned int nbProcs);
+ void setMaxDuration(const std::string& maxDuration);
+ std::string getMaxDuration() const;
void checkConsistency() const;
private:
YACSEvalParamsForCluster();