--exclude not being recognized as an argument


I’m getting the following error when I try to start annotating:

prodigy cta pilot spacy-ru/ru2 “post_files/check_annotator_thousand_shuffled.jsonl” -F code/recipe.py --label CTA --exclude pilot
usage: prodigy cta [-h] [-a None] [-lo None] [-l] dataset spacy_model source
prodigy cta: error: unrecognized arguments: --exclude pilot

Does --exclude not work for custom recipes?

Thank you,

It should be supported as a setting returned by your recipe, yes! But you do need to make it available as a command-line argument if you want to use it. The @recipe decorator lets you do that via the argument annotations – for example:

    dataset=("The dataset name", "positional"),
    exclude=("Datasets to exclude", "option", "e", str)
def your_custom_recipe(dataset, exclude):
    # exclude is a string, so if we want to support comma-separated lists,
    # we need to split it
    exclude = [name.strip() for name in exclude.split(",")]
    # your recipe code etc.
    return {
        'dataset': dataset,
        'exclude': exclude
        # and so on

The above setting will let you specify the exclude argument via --exclude or -e on the command line.

The argument annotations can be a tuple with the following settings: a human-readable description (displayed when you run --help), the argument type ("positional", "option" for an optional named argument, "flag" for a flag), a shortcut name (e.g. so you can use both --exclude and -e) and a type and/or converter function that’s called on the value set on the command-line before it’s passed to the function (default is str, but you could also use int to make sure you get an integer back). You can also find more details and examples in your PRODIGY_README.html.