Skip to content

Commit 64e70e5

Browse files
committed
[tmva][sofie] Make SOFIE Keras tutorials dependent on Keras version
The same was already done for the Keras unit tests when PyMVA and SOFIE were disentangled, but the same thing also has to be done for the tutorials.
1 parent 1d9d73c commit 64e70e5

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tutorials/CMakeLists.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,24 +345,43 @@ else()
345345
ROOT_FIND_PYTHON_MODULE(keras)
346346
ROOT_FIND_PYTHON_MODULE(sonnet)
347347
ROOT_FIND_PYTHON_MODULE(graph_nets)
348+
349+
# Check if we support the installed Keras version. Otherwise, veto SOFIE
350+
# Keras tutorials. This mirrors the logic in tmva/sofie/test/CMakeLists.txt.
351+
# TODO: make sure we also support the newest Keras
352+
set(unsupported_keras_version "3.5.0")
353+
if (NOT DEFINED ROOT_KERAS_VERSION)
354+
message(WARNING "Keras found, but version unknown — cannot verify compatibility.")
355+
elseif (NOT ROOT_KERAS_VERSION VERSION_LESS ${unsupported_keras_version})
356+
message(WARNING "Keras version ${ROOT_KERAS_VERSION} is too new for the SOFIE Keras parser (only supports < ${unsupported_keras_version}). Corresponding tutorials will not be tested.")
357+
set(keras_unsupported TRUE)
358+
endif()
359+
348360
if (NOT BLAS_FOUND)
349361
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_GNN_Application.C)
350362
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RDataFrame.C)
351363
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RSofieReader.C)
352364
endif()
353-
if (NOT tmva-sofie OR NOT ROOT_KERAS_FOUND)
365+
if (NOT tmva-sofie OR NOT ROOT_KERAS_FOUND OR keras_unsupported)
354366
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_Keras.C)
367+
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_Models.py)
355368
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_Keras_HiggsModel.C)
356369
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RDataFrame.C)
357370
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RDataFrame_JIT.C)
358371
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RSofieReader.C)
359372
endif()
373+
if (NOT tmva-pymva)
374+
# These SOFIE tutorials take models trained via PyMVA-PyKeras as input
375+
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_Keras_HiggsModel.C)
376+
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RDataFrame.C)
377+
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RDataFrame.py)
378+
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RSofieReader.C)
379+
endif()
360380
if (NOT tmva-sofie OR NOT ROOT_TORCH_FOUND)
361381
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_PyTorch.C)
362382
endif()
363383
if (NOT tmva-sofie)
364384
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_RDataFrame.py)
365-
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_Models.py)
366385
list(APPEND tmva_veto machine_learning/TMVA_SOFIE_Inference.py)
367386
endif()
368387
#veto this tutorial since it is added directly

0 commit comments

Comments
 (0)