From 7e60014f9e3fb0adf9fe5c713e921e5b7a8829ec Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Fri, 4 Sep 2026 12:00:55 +0000 Subject: [PATCH] [tmva] Deprecate PyMVA and the `tmva-pymva` build option PyMVA, the set of TMVA method plugins backed by Python machine-learning libraries (PyKeras, PyTorch, PyRandomForest, PyGTB and PyAdaBoost), is deprecated and scheduled for removal in ROOT 6.44. Like the SOFIE Keras and PyTorch parsers that are removed in this release cycle, PyMVA relies on implementation details of the underlying Python libraries that change faster than is appropriate for ROOT's stability standards. Users are encouraged to train and evaluate their models directly with the Python machine-learning libraries, which integrate well with the ROOT Python interface. For high-performance inference in C++, models can be exported to ONNX and evaluated with SOFIE. Besides the configure-time CMake deprecation warning, a runtime warning is emitted whenever a PyMVA method is constructed: PyMVA users typically consume ROOT as a pre-built binary (LCG, conda), so they would never see the configure-time message. --- README/ReleaseNotes/v642/index.md | 1 + cmake/modules/RootBuildOptions.cmake | 2 +- tmva/pymva/inc/TMVA/PyMethodBase.h | 2 ++ tmva/pymva/src/PyMethodBase.cxx | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README/ReleaseNotes/v642/index.md b/README/ReleaseNotes/v642/index.md index a62d10b760fcc..b080eb225e2ea 100644 --- a/README/ReleaseNotes/v642/index.md +++ b/README/ReleaseNotes/v642/index.md @@ -59,6 +59,7 @@ The following people have contributed to this new version: * The Keras and PyTorch parsers for SOFIE (`TMVA::Experimental::SOFIE::PyKeras` and `PyTorch`) are now removed, so `RSofieReader` only accepts ONNX files. These parsers relied on private implementation details of Keras and PyTorch, which change faster than is appropriate for ROOT's stability standards. Users are encouraged to export their models to ONNX and use the retained ONNX parser instead. +* **PyMVA**, the TMVA interface to Python machine-learning libraries (the `PyKeras`, `PyTorch`, `PyRandomForest`, `PyGTB` and `PyAdaBoost` methods), and the corresponding `tmva-pymva` build option are deprecated and will be removed in ROOT 6.44. Like the SOFIE Keras and PyTorch parsers, PyMVA relies on implementation details of the underlying Python libraries that change faster than is appropriate for ROOT's stability standards. Users are encouraged to train and evaluate their models directly with the Python machine-learning libraries, which integrate well with ROOT via the `ROOT::Experimental::ML::DataLoader`. For high-performance inference in C++, models can be exported to ONNX and evaluated with SOFIE (see `RSofieReader`). * The ROOT IO capability for the `TMVA::Experimental::RBDT` class has been removed, along with the `TMVA.Experimental.SaveXGBoost` Python function. Experimental classes should not be persistified since their on-disk layout is not guaranteed to be stable. An `RBDT` is now built directly from an XGBoost model in its native JSON serialization with the new `TMVA::Experimental::RBDT::LoadXGBoost(jsonPath)`, which works both from C++ and Python. To convert a trained model, save it first with XGBoost's `Booster.save_model("model.json")` and then load it with `LoadXGBoost`. * The **JsMVA** feature for interactive TMVA training in Jupyter notebooks is now removed. It was not functional for years and was therefore already excluded from ROOT 6.38. This also removes the `TMVA::IPythonInteractive` class and the related interactive-training interfaces from the TMVA method and fitter classes, such as `MethodBase::ExitFromTraining()` or `FitterBase::SetIPythonInteractive()`. * The **RooStats::DebuggingSampler** and **RooStats::DebuggingTestStat** classes are removed. They were mock implementations of the `TestStatSampler` and `TestStatistic` interfaces that returned uniform random numbers independent of the data, only meant for debugging the RooStats framework itself during its initial development. diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index 3948677fdc468..be3b19988076d 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -392,7 +392,7 @@ foreach(opt afdsmgrd afs alien bonjour builtin_afterimage builtin_davix builtin_ endforeach() #---Deprecated options------------------------------------------------------------------------ -foreach(opt mpi r) +foreach(opt mpi r tmva-pymva) if(${opt}) message(DEPRECATION ">>> Option '${opt}' is deprecated and will be removed in the next release of ROOT. Please contact root-dev@cern.ch should you still need it.") endif() diff --git a/tmva/pymva/inc/TMVA/PyMethodBase.h b/tmva/pymva/inc/TMVA/PyMethodBase.h index 1e622814ada8b..eb10f7794f7ee 100644 --- a/tmva/pymva/inc/TMVA/PyMethodBase.h +++ b/tmva/pymva/inc/TMVA/PyMethodBase.h @@ -113,6 +113,8 @@ namespace TMVA { void PyRunString(TString code, TString errorMessage="Failed to run python code", int start=256 /* Py_single_input */); // runs python code from string in local namespace with error handling private: + void PrintDeprecationWarning(); + static PyObject *fModuleBuiltin; static PyObject *fEval; // eval funtion from python static PyObject *fOpen; // open function for files diff --git a/tmva/pymva/src/PyMethodBase.cxx b/tmva/pymva/src/PyMethodBase.cxx index 035d15b4e172d..d8917207078a6 100644 --- a/tmva/pymva/src/PyMethodBase.cxx +++ b/tmva/pymva/src/PyMethodBase.cxx @@ -85,6 +85,8 @@ PyMethodBase::PyMethodBase(const TString &jobName, Types::EMVA methodType, const : MethodBase(jobName, methodType, methodTitle, dsi, theOption), fClassifier(NULL) { + PrintDeprecationWarning(); + if (!PyIsInitialized()) { PyInitialize(); } @@ -103,6 +105,8 @@ PyMethodBase::PyMethodBase(Types::EMVA methodType, const TString &weightFile): MethodBase(methodType, dsi, weightFile), fClassifier(NULL) { + PrintDeprecationWarning(); + if (!PyIsInitialized()) { PyInitialize(); } @@ -114,6 +118,18 @@ PyMethodBase::PyMethodBase(Types::EMVA methodType, } } +/////////////////////////////////////////////////////////////////////////////// +/// Warn that PyMVA is deprecated and scheduled for removal in ROOT 6.44. + +void PyMethodBase::PrintDeprecationWarning() +{ + Log() << kWARNING + << "PyMVA is deprecated and will be removed in ROOT 6.44. Please use the underlying Python " + "machine-learning packages directly, or export your model to ONNX and evaluate it with SOFIE " + "(see the RSofieReader class)." + << Endl; +} + /////////////////////////////////////////////////////////////////////////////// PyMethodBase::~PyMethodBase()