Skip to content

Commit

Permalink
add python3 cmsRun as PyDevParameterSet. Move everything to use Pytho…
Browse files Browse the repository at this point in the history
…nParameterSet
  • Loading branch information
davidlange6 committed Apr 6, 2019
1 parent cc6db46 commit 9e22e8d
Show file tree
Hide file tree
Showing 51 changed files with 3,174 additions and 190 deletions.
5 changes: 2 additions & 3 deletions FWCore/Framework/bin/BuildFile.xml
Expand Up @@ -70,7 +70,7 @@
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ParameterSetReader"/>
</bin>
<bin name="cmsRunBoostPython" file="cmsRunBoostPython.cpp">
<bin name="cmsRunPython3" file="cmsRunPython3.cpp">
<use name="tbb"/>
<use name="boost"/>
<use name="boost_program_options"/>
Expand All @@ -84,6 +84,5 @@
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Utilities"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PythonParameterSet"/>
<use name="boost_python"/>
<use name="FWCore/PyDevParameterSet"/>
</bin>
Expand Up @@ -24,7 +24,7 @@ PSet script. See notes in EventProcessor.cpp for details about it.
#include "FWCore/Utilities/interface/ConvertException.h"
#include "FWCore/Utilities/interface/Presence.h"
#include "FWCore/Utilities/interface/TimingServiceBase.h"
#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"
#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h"
#include "TError.h"

#include "boost/program_options.hpp"
Expand Down Expand Up @@ -277,7 +277,7 @@ int main(int argc, char* argv[]) {
context += fileName;
std::shared_ptr<edm::ProcessDesc> processDesc;
try {
std::unique_ptr<edm::ParameterSet> parameterSet = edm::boost_python::readConfig(fileName, argc, argv);
std::unique_ptr<edm::ParameterSet> parameterSet = edm::cmspybind11_p3::readConfig(fileName, argc, argv);
processDesc.reset(new edm::ProcessDesc(std::move(parameterSet)));
}
catch(cms::Exception& iException) {
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Integration/test/BuildFile.xml
Expand Up @@ -139,7 +139,7 @@
<bin file="SwitchProducer_t.cpp">
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PyDevParameterSet"/>
<use name="FWCore/PythonParameterSet"/>
<use name="FWCore/TestProcessor"/>
<use name="DataFormats/Provenance"/>
<use name="catch2"/>
Expand Down
2 changes: 1 addition & 1 deletion FWCore/Integration/test/SwitchProducer_t.cpp
Expand Up @@ -3,7 +3,7 @@

#include "DataFormats/TestObjects/interface/ToyProducts.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h"
#include "FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h"
#include "FWCore/TestProcessor/interface/TestProcessor.h"

#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSetReader/BuildFile.xml
@@ -1,5 +1,5 @@
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PyDevParameterSet"/>
<use name="FWCore/PythonParameterSet"/>
<export>
<lib name="1"/>
<use name="py2-pybind11"/>
Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSetReader/interface/ProcessDescImpl.h
@@ -1,7 +1,7 @@
#ifndef FWCore_Framework_ProcessDescImpl_h
#define FWCore_Framework_ProcessDescImpl_h

#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h"
#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h"

using ProcessDescImpl = PyBind11ProcessDesc;

Expand Down
4 changes: 2 additions & 2 deletions FWCore/ParameterSetReader/src/ParameterSetReader.cc
@@ -1,6 +1,6 @@
#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
#include "FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h"
#include "FWCore/PyDevParameterSet/interface/MakePyBind11ParameterSets.h"
#include "FWCore/PythonParameterSet/interface/PyBind11ProcessDesc.h"
#include "FWCore/PythonParameterSet/interface/MakePyBind11ParameterSets.h"

std::unique_ptr<edm::ParameterSet> edm::getPSetFromConfig(const std::string &config) {
return PyBind11ProcessDesc(config).parameterSet();
Expand Down
2 changes: 1 addition & 1 deletion FWCore/PyDevParameterSet/BuildFile.xml
Expand Up @@ -2,7 +2,7 @@
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>
<use name="py2-pybind11"/>
<use name="python"/>
<use name="python3"/>
<export>
<use name="py2-pybind11"/>
<lib name="1"/>
Expand Down
@@ -1,5 +1,5 @@
#ifndef FWCore_PyBind11ParameterSet_MakePyBind11ParameterSets_h
#define FWCore_PyBind11ParameterSet_MakePyBind11ParameterSets_h
#ifndef FWCore_PyDevParameterSet_MakePyBind11ParameterSets_h
#define FWCore_PyDevParameterSet_MakePyBind11ParameterSets_h

//----------------------------------------------------------------------
// Declare functions used to create ParameterSets.
Expand All @@ -12,7 +12,7 @@

namespace edm {
class ParameterSet;
namespace cmspybind11 {
namespace cmspybind11_p3 {
// input can either be a python file name or a python config string
std::unique_ptr<ParameterSet>
readConfig(std::string const& config);
Expand Down
7 changes: 5 additions & 2 deletions FWCore/PyDevParameterSet/interface/PyBind11ProcessDesc.h
@@ -1,5 +1,5 @@
#ifndef FWCore_PyBind11ParameterSet_PyBind11ProcessDesc_h
#define FWCore_PyBind11ParameterSet_PyBind11ProcessDesc_h
#ifndef FWCore_PyDevParameterSet_PyBind11ProcessDesc_h
#define FWCore_PyDevParameterSet_PyBind11ProcessDesc_h

#include "FWCore/PyDevParameterSet/interface/Python11ParameterSet.h"

Expand All @@ -13,6 +13,8 @@ namespace edm {
class ProcessDesc;
}

namespace cmspython3 {

class PyBind11ProcessDesc {
public:
PyBind11ProcessDesc();
Expand Down Expand Up @@ -53,4 +55,5 @@ class PyBind11ProcessDesc {
bool theOwnsInterpreter;
};

}
#endif
6 changes: 3 additions & 3 deletions FWCore/PyDevParameterSet/interface/PyBind11Wrapper.h
@@ -1,13 +1,13 @@
#ifndef FWCore_PyBind11ParameterSet_PyBind11Wrapper_h
#define FWCore_PyBind11ParameterSet_PyBind11Wrapper_h
#ifndef FWCore_PyDevParameterSet_PyBind11Wrapper_h
#define FWCore_PyDevParameterSet_PyBind11Wrapper_h

#include <vector>
#include <string>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <iostream>

namespace edm {
namespace cmspython3 {
void
pythonToCppException(const std::string& iType, const std::string& error);

Expand Down
11 changes: 6 additions & 5 deletions FWCore/PyDevParameterSet/interface/Python11ParameterSet.h
@@ -1,5 +1,5 @@
#ifndef FWCore_PyBind11ParameterSet_Python11ParameterSet_h
#define FWCore_PyBind11ParameterSet_Python11ParameterSet_h
#ifndef FWCore_PyDevParameterSet_Python11ParameterSet_h
#define FWCore_PyDevParameterSet_Python11ParameterSet_h
#include <pybind11/pybind11.h>

#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -16,6 +16,7 @@
#include <string>
#include <vector>

namespace cmspython3 {
class Python11ParameterSet {
public:
Python11ParameterSet();
Expand Down Expand Up @@ -52,15 +53,15 @@ class Python11ParameterSet {
pybind11::list
getParameters(bool tracked, std::string const& name) const {
std::vector<T> v = getParameter<std::vector<T> >(tracked, name);
return edm::toPython11List(v);
return cmspython3::toPython11List(v);
}

/// unfortunate side effect: destroys the original list!
template<typename T>
void
addParameters(bool tracked, std::string const& name,
pybind11::list value) {
std::vector<T> v = edm::toVector<T>(value);
std::vector<T> v = cmspython3::toVector<T>(value);
addParameter(tracked, name, v);
}

Expand Down Expand Up @@ -127,5 +128,5 @@ class Python11ParameterSet {
private:
edm::ParameterSet theParameterSet;
};

}
#endif

0 comments on commit 9e22e8d

Please sign in to comment.