fix for custom pipeline configuration (#29004)
* fix for custom pipeline configuration * fix for custom pipelines * remove extra exception * added test for custom pipelines extra tag * format with ruff * limit extra tag for first time only * format with ruff * improve tests for custom pipelines
This commit is contained in:
@@ -925,6 +925,24 @@ class DynamicPipelineTester(unittest.TestCase):
|
||||
# Can't make an isinstance check because the new_classifier is from the PairClassificationPipeline class of a
|
||||
# dynamic module
|
||||
self.assertEqual(new_classifier.__class__.__name__, "PairClassificationPipeline")
|
||||
# check for tag exitence, tag needs to be added when we are calling a custom pipeline from the hub
|
||||
# useful for cases such as finetuning
|
||||
self.assertDictEqual(
|
||||
new_classifier.model.config.custom_pipelines,
|
||||
{
|
||||
"pair-classification": {
|
||||
"impl": f"{USER}/test-dynamic-pipeline--custom_pipeline.PairClassificationPipeline",
|
||||
"pt": ("AutoModelForSequenceClassification",),
|
||||
"tf": (),
|
||||
}
|
||||
},
|
||||
)
|
||||
# test if the pipeline still works after the model is finetuned
|
||||
# (we are actually testing if the pipeline still works from the final repo)
|
||||
# this is where the user/repo--module.class is used for
|
||||
new_classifier.model.push_to_hub(repo_name=f"{USER}/test-pipeline-for-a-finetuned-model", token=self._token)
|
||||
del new_classifier # free up memory
|
||||
new_classifier = pipeline(model=f"{USER}/test-pipeline-for-a-finetuned-model", trust_remote_code=True)
|
||||
|
||||
results = classifier("I hate you", second_text="I love you")
|
||||
new_results = new_classifier("I hate you", second_text="I love you")
|
||||
|
||||
Reference in New Issue
Block a user