CMS 3D CMS Logo

Functions
edm::cmspybind11_p3 Namespace Reference

Functions

void makeParameterSets (std::string const &configtext, std::unique_ptr< ParameterSet > &main)
 essentially the same as the previous method More...
 
std::unique_ptr< ParameterSetreadConfig (std::string const &config)
 
std::unique_ptr< ParameterSetreadConfig (std::string const &config, int argc, char *argv[])
 same, but with arguments More...
 
std::unique_ptr< ParameterSetreadPSetsFrom (std::string const &fileOrString)
 

Function Documentation

◆ makeParameterSets()

void edm::cmspybind11_p3::makeParameterSets ( std::string const &  configtext,
std::unique_ptr< ParameterSet > &  main 
)

essentially the same as the previous method

Definition at line 36 of file MakePyBind11ParameterSets.cc.

36  {
37  cmspython3::PyBind11ProcessDesc pythonProcessDesc(configtext);
38  main = pythonProcessDesc.parameterSet();
39  }

References cmspython3::PyBind11ProcessDesc::parameterSet().

◆ readConfig() [1/2]

std::unique_ptr< ParameterSet > edm::cmspybind11_p3::readConfig ( std::string const &  config)

Definition at line 26 of file MakePyBind11ParameterSets.cc.

26  {
27  cmspython3::PyBind11ProcessDesc pythonProcessDesc(config);
28  return pythonProcessDesc.parameterSet();
29  }

References cmspython3::PyBind11ProcessDesc::parameterSet().

◆ readConfig() [2/2]

std::unique_ptr< ParameterSet > edm::cmspybind11_p3::readConfig ( std::string const &  config,
int  argc,
char *  argv[] 
)

same, but with arguments

Definition at line 31 of file MakePyBind11ParameterSets.cc.

31  {
32  cmspython3::PyBind11ProcessDesc pythonProcessDesc(config, argc, argv);
33  return pythonProcessDesc.parameterSet();
34  }

References dir2webdir::argc, cmsBatch::argv, and cmspython3::PyBind11ProcessDesc::parameterSet().

◆ readPSetsFrom()

std::unique_ptr< ParameterSet > edm::cmspybind11_p3::readPSetsFrom ( std::string const &  fileOrString)

finds all the PSets used in the top level module referred as a file or as a string containing python commands. These PSets are bundled into a top level PSet from which they can be retrieved

Definition at line 41 of file MakePyBind11ParameterSets.cc.

41  {
42  pybind11::scoped_interpreter guard{};
44  std::unique_ptr<ParameterSet> retVal;
45  {
46  cmspython3::Python11ParameterSet theProcessPSet;
47  pybind11::object mainModule = pybind11::module::import("__main__");
48  mainModule.attr("topPSet") = pybind11::cast(&theProcessPSet);
49 
50  try {
51  // if it ends with py, it's a file
52  if (module.substr(module.size() - 3) == ".py") {
54  } else {
56  }
57  } catch (pybind11::error_already_set const& e) {
58  cmspython3::pythonToCppException("Configuration", e.what());
59  }
60  retVal = std::make_unique<edm::ParameterSet>(ParameterSet(theProcessPSet.pset()));
61  }
62  return retVal;
63  }

References MillePedeFileConverter_cfg::e, cond::persistency::import(), edm::python3::initializePyBind11Module(), makePSetsFromFile(), makePSetsFromString(), resolutioncreator_cfi::object, cmspython3::Python11ParameterSet::pset(), and cmspython3::pythonToCppException().

cmsBatch.argv
argv
Definition: cmsBatch.py:279
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
dir2webdir.argc
argc
Definition: dir2webdir.py:39
cmspython3::PyBind11ProcessDesc
Definition: PyBind11ProcessDesc.h:18
makePSetsFromFile
static void makePSetsFromFile(std::string const &fileName)
Definition: MakePyBind11ParameterSets.cc:9
config
Definition: config.py:1
makePSetsFromString
static void makePSetsFromString(std::string const &module)
Definition: MakePyBind11ParameterSets.cc:18
ParameterSet
Definition: Functions.h:16
edm::python3::initializePyBind11Module
void initializePyBind11Module()
Definition: initializePyBind11Module.cc:14
cmspython3::pythonToCppException
void pythonToCppException(const std::string &iType, const std::string &error)
Definition: PyBind11Wrapper.cc:6
module
Definition: vlib.h:198
main
Definition: main.py:1
cmspython3::Python11ParameterSet
Definition: Python11ParameterSet.h:20
cond::persistency::import
cond::Hash import(Session &source, const cond::Hash &sourcePayloadId, const std::string &inputTypeName, const void *inputPtr, Session &destination)
Definition: CondDBImport.cc:39
cmspython3::Python11ParameterSet::pset
edm::ParameterSet & pset()
Definition: Python11ParameterSet.h:112
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37