From 21943aa305c64c6db79af440b4a1152b64cad38b Mon Sep 17 00:00:00 2001 From: fxmarty <9808326+fxmarty@users.noreply.github.com> Date: Wed, 19 Jul 2023 17:24:30 +0200 Subject: [PATCH] Fix ORT test for unknown architecture for task (#1212) * fix * fix style * git old test --- optimum/exporters/onnx/__main__.py | 2 +- tests/exporters/onnx/test_onnx_export.py | 2 +- tests/onnxruntime/test_modeling.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/optimum/exporters/onnx/__main__.py b/optimum/exporters/onnx/__main__.py index 696cb86823..6cefc7c571 100644 --- a/optimum/exporters/onnx/__main__.py +++ b/optimum/exporters/onnx/__main__.py @@ -322,7 +322,7 @@ def main_export( # TODO: support onnx_config.py in the model repo if custom_architecture and custom_onnx_configs is None: raise ValueError( - "Trying to export a model with a custom architecture, but no custom onnx configuration was passed as `custom_onnx_configs`. Please refer to https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/export_a_model#custom-export-of-transformers-models for an example on how to export custom models." + f"Trying to export a {model.config.model_type.replace('-', '_')} model, that is a custom or unsupported architecture for the task {task}, but no custom onnx configuration was passed as `custom_onnx_configs`. Please refer to https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/export_a_model#custom-export-of-transformers-models for an example on how to export custom models. For the task {task}, the Optimum ONNX exporter supports natively the architectures: {TasksManager.get_supported_model_type_for_task(task, exporter='onnx')}." ) if custom_architecture and original_task == "auto": diff --git a/tests/exporters/onnx/test_onnx_export.py b/tests/exporters/onnx/test_onnx_export.py index c97c9ff58c..9a96d13e47 100644 --- a/tests/exporters/onnx/test_onnx_export.py +++ b/tests/exporters/onnx/test_onnx_export.py @@ -587,4 +587,4 @@ def test_custom_export_trust_remote_error(self): no_post_process=True, ) - self.assertIn("export a model with a custom architecture, but no custom onnx", str(context.exception)) + self.assertIn("custom or unsupported architecture", str(context.exception)) diff --git a/tests/onnxruntime/test_modeling.py b/tests/onnxruntime/test_modeling.py index b7dc9ca381..0ba847a0d6 100644 --- a/tests/onnxruntime/test_modeling.py +++ b/tests/onnxruntime/test_modeling.py @@ -1089,7 +1089,7 @@ def test_load_vanilla_transformers_which_is_not_supported(self): with self.assertRaises(Exception) as context: _ = ORTModelForQuestionAnswering.from_pretrained(MODEL_NAMES["t5"], export=True) - self.assertIn("Unrecognized configuration class", str(context.exception)) + self.assertIn("custom or unsupported architecture", str(context.exception)) @parameterized.expand(SUPPORTED_ARCHITECTURES) def test_compare_to_transformers(self, model_arch):