Use a custom on_exit function with ner.match

I want to perform an on_exit function while using the built in ner.match recipe. I have gone through the provided documents and i cannot seem to figure out how to add the on_exit function to the ner.match recipe

My code rn looks something like this

import prodigy
from import match

def custom_ner_match(dataset, spacy_model, source, patterns):
    """Custom wrapper for ner.teach recipe that replaces the stream."""
    components = match(dataset=dataset, spacy_model=spacy_model,
                    source=source, patterns=patterns)
    return components

def on_exit(controller):
    """DO SOMETHING"""


Hi! You're almost there :slightly_smiling_face: But to make the on_exit function available to your recipe and Prodigy, you actually need to return it as part of the components returned by the recipe.

In your code, components is the dict that's typically returned by recipes – e.g. {"dataset": dataset, "stream": stream} and so on. So before you return components, you need to add the on_exit:

components["on_exit"] = on_exit