File indexing completed on 2024-04-06 12:13:00
0001 #ifndef FWCore_PythonFramework_PythonModule_h
0002 #define FWCore_PythonFramework_PythonModule_h
0003
0004 #include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h"
0005
0006 #include "FWCore/PythonFramework/interface/PythonEventProcessor.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008
0009 #include <pybind11/pybind11.h>
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 PYBIND11_MODULE(libFWCorePythonFramework, m) {
0022 pybind11::register_exception_translator([](std::exception_ptr p) {
0023 try {
0024 if (p)
0025 std::rethrow_exception(p);
0026 } catch (const cms::Exception &e) {
0027 PyErr_SetString(PyExc_RuntimeError, e.what());
0028 }
0029 });
0030
0031 pybind11::class_<PythonEventProcessor>(m, "PythonEventProcessor")
0032 .def(pybind11::init<PyBind11ProcessDesc const &>())
0033 .def("run", &PythonEventProcessor::run)
0034 .def("totalEvents", &PythonEventProcessor::totalEvents)
0035 .def("totalEventsPassed", &PythonEventProcessor::totalEventsPassed)
0036 .def("totalEventsFailed", &PythonEventProcessor::totalEventsFailed);
0037 }
0038 #endif