@@ -128,12 +128,26 @@ def apply_onnx_classification_model(
128128 """
129129 Apply an ONNX classification model `fit` to a pandas dataframe `data_pd`.
130130
131+ .. note::
132+ This function requires the ``onnx`` and ``onnxruntime`` packages, which
133+ are not included in the default gnomad_methods dependencies because they
134+ conflict with hailctl's protobuf pin. Install them separately with
135+ ``pip install onnx onnxruntime``.
136+
131137 :param data_pd: Pandas dataframe containing the data to be classified.
132138 :param fit: ONNX model to be applied.
133139 :return: Tuple of classification and probabilities.
134140 """
135- import onnx # pylint: disable=import-error
136- import onnxruntime as rt # pylint: disable=import-error
141+ try :
142+ import onnx # pylint: disable=import-error
143+ import onnxruntime as rt # pylint: disable=import-error
144+ except ImportError as e :
145+ raise ImportError (
146+ "This function requires the 'onnx' and 'onnxruntime' packages, which"
147+ " are not included in the default gnomad_methods dependencies because"
148+ " they conflict with hailctl's protobuf pin. Install them with:"
149+ " pip install onnx onnxruntime"
150+ ) from e
137151
138152 if not isinstance (fit , onnx .ModelProto ):
139153 raise TypeError ("The model supplied is not an onnx model!" )
@@ -184,14 +198,28 @@ def convert_sklearn_rf_to_onnx(fit: Any, target_opset: Optional[int] = None) ->
184198 """
185199 Convert a sklearn random forest model to ONNX.
186200
201+ .. note::
202+ This function requires the ``skl2onnx`` package, which is not included
203+ in the default gnomad_methods dependencies because onnx packages conflict
204+ with hailctl's protobuf pin. Install it separately with
205+ ``pip install skl2onnx``.
206+
187207 :param fit: Sklearn random forest model to be converted.
188208 :param target_opset: An optional target ONNX opset version to convert the model to.
189209 :return: ONNX model.
190210 """
191- from skl2onnx import convert_sklearn # pylint: disable=import-error
192- from skl2onnx .common .data_types import ( # pylint: disable=import-error
193- FloatTensorType ,
194- )
211+ try :
212+ from skl2onnx import convert_sklearn # pylint: disable=import-error
213+ from skl2onnx .common .data_types import ( # pylint: disable=import-error
214+ FloatTensorType ,
215+ )
216+ except ImportError as e :
217+ raise ImportError (
218+ "This function requires the 'skl2onnx' package, which is not"
219+ " included in the default gnomad_methods dependencies because onnx"
220+ " packages conflict with hailctl's protobuf pin. Install it with:"
221+ " pip install skl2onnx"
222+ ) from e
195223 from sklearn .utils .validation import check_is_fitted
196224
197225 try :
0 commit comments