Configures the framework.
82 ROOT::EnableThreadSafety();
96 ERS_LOG(
"---> Dump of config cache: \n" <<
m_config->dumpOptions() );
97 ERS_LOG(
"---> Pesa JobOptions file is = " <<
m_config->getOption(
"JOBOPTIONSPATH") );
102 ERS_DEBUG(1,
"---> Create Pesa Application Manager");
112 ERS_DEBUG(1,
"---> Configure Pesa Property Manager");
114 if( !propMgr.isValid() ) {
115 ERS_PSC_ERROR(
"Error retrieving IProperty interface of ApplicationMgr");
121 sc = propMgr->setProperty(
"JobOptionsSvcType",
m_config->getOption(
"JOBOPTIONSSVCTYPE"));
122 if (
sc.isFailure()) {
128 sc = propMgr->setProperty(
"JobOptionsType",
m_config->getOption(
"JOBOPTIONSTYPE"));
129 if (
sc.isFailure()) {
135 sc = propMgr->setProperty(
"JobOptionsPath",
m_config->getOption(
"JOBOPTIONSPATH") );
136 if (
sc.isFailure()) {
142 sc = propMgr->setProperty(
"MessageSvcType",
m_config->getOption(
"MESSAGESVCTYPE"));
143 if (
sc.isFailure()) {
152 bool jobOptConfig, needPython;
153 if (
m_config->getOption(
"JOBOPTIONSTYPE") ==
"NONE" ) {
154 jobOptConfig = needPython =
true;
156 else if (
m_config->getOption(
"JOBOPTIONSTYPE") ==
"DB" ||
157 m_config->getOption(
"JOBOPTIONSTYPE") ==
"FILE") {
158 jobOptConfig = needPython =
false;
159 if ( (
m_config->getOption(
"PRECOMMAND")!=
"") || (
m_config->getOption(
"POSTCOMMAND")!=
"") ) {
162 if (
m_config->didUserSetLogLevel()) {
167 ERS_PSC_ERROR(
"Unsupported configuration method \"" <<
m_config->getOption(
"JOBOPTIONSTYPE") <<
"\"");
172 if ( jobOptConfig || needPython ) {
178 if ( ! Py_IsInitialized() ) {
179 ERS_DEBUG(1,
"Initializing Python interpreter");
182 PyConfig_InitPythonConfig (&
config);
184 if (PyStatus_Exception (
status)) {
190 if (PyStatus_Exception (
status)) {
201 if ( ! Py_IsInitialized() ) {
208 ERS_DEBUG(1,
"Python interpreter already initialized");
213 PyObject* pModule = PyImport_ImportModule(
"TrigPSC.PscConfig");
217 std::map<std::string,std::string>::const_iterator iter;
219 PyObject*
v = PyUnicode_FromString(iter->second.c_str());
220 std::vector<char> writable(iter->first.size() + 1);
221 std::copy(iter->first.begin(), iter->first.end(), writable.begin());
222 PyMapping_SetItemString(
optmap, &writable[0],
v);
227 ERS_DEBUG(1,
"Could not import TrigPSC.PscConfig.optmap");
233 if ( jobOptConfig ) {
235 std::string pyBasicFile =
m_config->getOption(
"PYTHONSETUPFILE") ;
242 if ( !jobOptConfig ) {
248 std::string
cmd =
m_config->getOption(
"PRECOMMAND");
250 ERS_LOG(
"Running pre-configure command '" <<
cmd <<
"'");
258 ERS_DEBUG(1,
"Configure ApplicationMgr from database.");
260 if(
sc.isFailure() ) {
268 std::string pyBasicFile =
m_config->getOption(
"PYTHONSETUPFILE",
true) ;
269 if ( !pyBasicFile.empty() ) {
281 PyObject* pModule = PyImport_ImportModule(
"TrigPSC.PscConfig");
283 PyObject* pInteractive = PyObject_GetAttrString(pModule,
"interactive");
284 if ( pInteractive && PyBool_Check(pInteractive) ) {
286 ERS_DEBUG(1,
"TrigPSC.PscConfig.interactive = " <<
m_interactive);
287 Py_DECREF(pInteractive);
290 ERS_DEBUG(1,
"Could not read TrigPSC.PscConfig.interactive");
295 ERS_DEBUG(1,
"Could not import TrigPSC.PscConfig");
301 ERS_DEBUG(1,
"Configured ApplicationMgr in state: " <<
m_pesaAppMgr->FSMState());
304 SmartIF<IProperty> jos_propif{&(*jobOptionSvc)};
306 jos_propif->setProperty(
"OutputLevel",
m_config->getLogLevelAsNumStr()).ignore();
311 auto props = std::map<std::string,std::string>{
312 {
"DF_PartitionName",
"DF_PARTITION_NAME"},
313 {
"DF_ApplicationName",
"DF_APPLICATIONNAME"},
314 {
"DF_MachineName",
"DF_MACHINE_NAME"},
315 {
"DF_Ppid",
"DF_PPID"},
316 {
"DF_Pid",
"DF_PID"},
317 {
"DF_HostId",
"DF_HOST_ID"},
318 {
"DF_RandomSeed",
"DF_RANDOM_SEED"},
319 {
"DF_NumberOfWorkers",
"NPROCS"}
325 if (
m_config->enabled_robs.size() != 0 ) {
326 jobOptionSvc->set(
"DataFlowConfig.DF_Enabled_ROB_IDs",
328 ERS_DEBUG(1,
"psc::Psc::configure: Wrote configuration for enabled ROBs in JobOptions Catalogue: "
329 <<
" number of ROB IDs read from OKS = " <<
m_config->enabled_robs.size());
333 if (
m_config->enabled_SubDets.size() != 0 ) {
334 jobOptionSvc->set(
"DataFlowConfig.DF_Enabled_SubDet_IDs",
336 ERS_DEBUG(1,
"psc::Psc::configure: Wrote configuration for enabled sub detectors in JobOptions Catalogue: "
337 <<
" number of Sub Det IDs read from OKS = " <<
m_config->enabled_SubDets.size());
341 if (std::string
opt =
m_config->getOption(
"MAXEVENTSIZEMB"); !
opt.empty()) {
342 jobOptionSvc->set(
"DataFlowConfig.DF_MaxEventSizeMB",
opt);
343 ERS_DEBUG(1,
"psc::Psc::configure: Wrote DF_MaxEventSizeMB=" <<
opt <<
" in JobOptions Catalogue");
347 if ( (
m_config->getOption(
"MUONCALBUFFERNAME") !=
"NONE") && (
m_config->getOption(
"MUONCALBUFFERNAME") !=
"") ) {
348 jobOptionSvc->set(
"MuonHltCalibrationConfig.MuonCalBufferName",
m_config->getOption(
"MUONCALBUFFERNAME"));
349 jobOptionSvc->set(
"MuonHltCalibrationConfig.MuonCalBufferSize",
m_config->getOption(
"MUONCALBUFFERSIZE"));
351 ERS_DEBUG(1,
"psc::Psc::configure: Wrote configuration for HLT Muon Calibration in JobOptions Catalogue: "
352 <<
" MuonCalBufferName = " <<
m_config->getOption(
"MUONCALBUFFERNAME")
353 <<
" MuonCalBufferSize = " <<
m_config->getOption(
"MUONCALBUFFERSIZE") );
359 if ( !jobOptConfig ) {
361 std::string
cmd =
m_config->getOption(
"POSTCOMMAND");
363 ERS_LOG(
"Running post-configure command '" <<
cmd <<
"'");