@@ -597,31 +597,32 @@ def add_model(
597
597
) from None
598
598
599
599
# explainability tokenizer
600
- if not isinstance (explainability_tokenizer , Callable ):
601
- raise UnboxValidationError (
602
- f"- `{ explainability_tokenizer } ` specified as `explainability_tokenizer` is not callable. \n "
603
- ) from None
604
-
605
- if model_type != ModelType .custom :
606
- try :
607
- if task_type in [TaskType .TextClassification ]:
608
- test_input = [
609
- "Unbox is great!" ,
610
- "Let's see if this function is ready for some error analysis" ,
611
- ]
612
- with HidePrints ():
613
- function (model , test_input , ** kwargs )
614
- except Exception as e :
615
- exception_stack = "" .join (
616
- traceback .format_exception (type (e ), e , e .__traceback__ )
617
- )
618
- raise UnboxResourceError (
619
- context = "There is an issue with the specified `explainability_tokenizer`. \n " ,
620
- message = f"It is failing with the following error: \n { exception_stack } " ,
621
- mitigation = "Make sure your `explainability_tokenizer` receives a list of sentences as input and returns a list of lists of tokens "
622
- + "as output. Additionally, you may find it useful to debug it on the Jupyter notebook, to ensure it is working correctly before uploading it." ,
600
+ if explainability_tokenizer :
601
+ if not isinstance (explainability_tokenizer , Callable ):
602
+ raise UnboxValidationError (
603
+ f"- `{ explainability_tokenizer } ` specified as `explainability_tokenizer` is not callable. \n "
623
604
) from None
624
605
606
+ if model_type != ModelType .custom :
607
+ try :
608
+ if task_type in [TaskType .TextClassification ]:
609
+ test_input = [
610
+ "Unbox is great!" ,
611
+ "Let's see if this function is ready for some error analysis" ,
612
+ ]
613
+ with HidePrints ():
614
+ function (model , test_input , ** kwargs )
615
+ except Exception as e :
616
+ exception_stack = "" .join (
617
+ traceback .format_exception (type (e ), e , e .__traceback__ )
618
+ )
619
+ raise UnboxResourceError (
620
+ context = "There is an issue with the specified `explainability_tokenizer`. \n " ,
621
+ message = f"It is failing with the following error: \n { exception_stack } " ,
622
+ mitigation = "Make sure your `explainability_tokenizer` receives a list of sentences as input and returns a list of lists of tokens "
623
+ + "as output. Additionally, you may find it useful to debug it on the Jupyter notebook, to ensure it is working correctly before uploading it." ,
624
+ ) from None
625
+
625
626
# Transformers resources
626
627
if model_type is ModelType .transformers :
627
628
if "tokenizer" not in kwargs :
0 commit comments