Skip to content

Commit 8a4a8cb

Browse files
committed
[tmva][sofie] Require onnx!=1.19.0 for tests
The Python package onnx 1.19.0 has a bug that makes this version unusable: onnx/onnx#7249 In that case, we have to disable the "TestSofieModels" and "TestRModelParserPyTorch" tests, which import onnx indirectly via `torch.onnx`. We should also consider to require `onnx!=1.19.1` in our `requirements.txt` in the future, so our users don't face similar trouble from exporting PyTorch models to onnx. But this should only be done once we are sure that it can also be installed on macOS without breaking something else. Closes #20571.
1 parent 4423fd5 commit 8a4a8cb

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

tmva/sofie/test/CMakeLists.txt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,21 @@ endif()
109109
ROOT_FIND_PYTHON_MODULE(torch)
110110
ROOT_FIND_PYTHON_MODULE(keras)
111111

112-
if (ROOT_TORCH_FOUND)
112+
113+
114+
# onnx 1.19.0 has a bug that makes this version unusable:
115+
# https://github.com/onnx/onnx/issues/7249
116+
# In that case, we have to disable the "TestSofieModels" and
117+
# "TestRModelParserPyTorch" tests, which import onnx indirectly via torch.onnx
118+
ROOT_FIND_PYTHON_MODULE(onnx)
119+
if (ROOT_ONNX_FOUND AND DEFINED ROOT_ONNX_VERSION)
120+
if(ROOT_ONNX_VERSION VERSION_EQUAL "1.19.0")
121+
message(WARNING "Found broken onnx version ${ROOT_ONNX_VERSION} (see https://github.com/onnx/onnx/issues/7249). Some TMVA SOFIE tests will be disabled.")
122+
set(broken_onnx TRUE)
123+
endif()
124+
endif()
125+
126+
if (ROOT_TORCH_FOUND AND ROOT_ONNX_FOUND AND NOT broken_onnx)
113127
configure_file(Conv1dModelGenerator.py Conv1dModelGenerator.py COPYONLY)
114128
configure_file(Conv2dModelGenerator.py Conv2dModelGenerator.py COPYONLY)
115129
configure_file(Conv3dModelGenerator.py Conv3dModelGenerator.py COPYONLY)
@@ -129,8 +143,8 @@ if (ROOT_TORCH_FOUND)
129143
endif()
130144
endif()
131145

132-
# Any reatures that link against libpython are disabled if built with tpython=OFF
133-
if (tpython AND ROOT_TORCH_FOUND AND BLAS_FOUND)
146+
# Any features that link against libpython are disabled if built with tpython=OFF
147+
if (tpython AND ROOT_TORCH_FOUND AND ROOT_ONNX_FOUND AND BLAS_FOUND AND NOT broken_onnx)
134148
configure_file(generatePyTorchModelClassification.py generatePyTorchModelClassification.py COPYONLY)
135149
configure_file(generatePyTorchModelMulticlass.py generatePyTorchModelMulticlass.py COPYONLY)
136150
configure_file(generatePyTorchModelRegression.py generatePyTorchModelRegression.py COPYONLY)
@@ -151,7 +165,7 @@ if (tpython AND ROOT_TORCH_FOUND AND BLAS_FOUND)
151165
endif()
152166

153167

154-
# Any reatures that link against libpython are disabled if built with tpython=OFF
168+
# Any features that link against libpython are disabled if built with tpython=OFF
155169
if (tpython AND ROOT_KERAS_FOUND AND BLAS_FOUND)
156170

157171
set(unsupported_keras_version "3.5.0")

0 commit comments

Comments
 (0)