# Run through python script.

**URL:** <https://support.prodi.gy/t/run-through-python-script/339>\
**Category:** Uncategorized\
**Tags:** usage, solved\
**Created:** [February 25, 2018, 2:58pm UTC](https://support.prodi.gy/t/run-through-python-script/339 "2018-02-25T14:58:06Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![iero](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@iero](https://support.prodi.gy/u/iero)\
**Post date:** [April 2, 2019, 11:32pm UTC](https://support.prodi.gy/t/run-through-python-script/339/13 "2019-04-02T23:32:30Z")

</div>

Hi

I have the same need : I launch a custom ner.teach recipe using `prodigy.serve('my.ner.teach')` function and I move to my browser to annotate.

```python
def ner_teach(dataset, spacy_model, source=None, label=None, patterns=None,
              exclude=None, unsegmented=False):
    logger.info("Entering ner.teach process")
    stream = source
    nlp = spacy.load(spacy_model)

    model = EntityRecognizer(nlp, label=label)

    if patterns is None:
        predict = model
        update = model.update
    else:
        matcher = PatternMatcher(nlp)
        matcher.add_patterns(patterns)

        predict, update = combine_models(model, matcher)

    if not unsegmented:
        stream = split_sentences(nlp, stream)

    stream = prefer_uncertain(predict(stream))

    return {
        'view_id': 'ner', # Annotation interface to use
        'dataset': dataset, # Name of dataset to save annotations
        'stream': stream, # Incoming stream of examples
        'update': update, # Update callback, called with batch of answers
        'exclude': exclude, # List of dataset names to exclude
        'config': { # Additional config settings, mostly for app UI
            'lang': nlp.lang,
            'label': ', '.join(label) if label is not None else 'all'
        }
    }

```

At the end, I have a `No tasks available.` message.

Is it possible to automate the “save to dataset” and kill the server whithout having to do the save manualy and close the server using ctrl-c in the console ?

According to [this post](https://support.prodi.gy/t/alternative-exit-to-quit-in-terminal/569), it seems that we could do that using a modification of the custom recipe, but I don’t know how…

After the teaching, I would like to analyse the dataset, retrain and compare with the results from last training.

Thanks

---

_[View the full topic](https://support.prodi.gy/t/run-through-python-script/339)._
