AttributeError: 'PosixPath' object has no attribute 'isfile' for custom recipe

Hi, I’m making a custom recipe and I wanted to point out the follow error when I run your example at

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/whigh/venvs/clearance/lib/python3.6/site-packages/prodigy/", line 260, in <module>
    if not recipe_path.isfile():
AttributeError: 'PosixPath' object has no attribute 'isfile'

I have worked around it with os.path.isfile(str(recipe_path)).

I’m using Python 3.6.4.

Oh no, looks like we broke this in the latest release when we fixed the error messages for custom recipes :woman_facepalming: No idea how this bypassed our tests. Another quick fix would be to change isfile to is_file.

Just rebuilding the wheels and will release v1.4.2 asap!

You rock!


I just investigated this and turns out it’s not quite as bad as I thought: It looks like this code is only executed if the recipe plus recipe path supplied on the command line can’t be resolved to a recipe function. This either happens if the path doesn’t exist or the recipe function can’t be found within the file. (So essentially, Prodigy fails on displaying the error message, which is especially frustrating.)

@ines I am currently working on my very first recipe and got the same error 'PosixPath' object has no attribute 'isfile'. However, I can’t seem to fix it. I am using v1.4.1. on Python 3.6.3. Here is what my recipe looks like:

import prodigy
from prodigy.components.loaders import CSV


                file_path=("./path_to_file.csv", "positional", None, str))

def my_recipe(dataset, file_path):

    stream = CSV(file_path)
    stream = add_options(stream)

    return {
        'dataset': dataset,
        'view_id': 'choice',
        'stream': stream,

def add_options(stream):
    options = [{'id': '1', 'text': 'Class 1'},
               {'id': '2', 'text': 'Class 2'},
               {'id': '3', 'text': 'Class 3'}]

    for task in stream:
        task['options'] = options
        yield task

@MatthewC Sorry about this issue – as I mentioned above, this is a bug in the error message, which is extra frustrating. We’re planning on pushing another small point release today that fixes this (among other things).

Looking at your recipe, I see one main problem:

file_path=("./path_to_file.csv", "positional", None, str))

The recipe arguments are supposed to be argument annotations – i.e. tuples describing the arguments you want to pass in via the command line. The recipe_args are a dictionary of a few pre-defined ones to reuse – for example, recipe_args['dataset']. So the following arguments…

file_path=("The path to the CSV file", "positional", None, str))

… would let you use your recipe like this:

prodigy my_recipe your_dataset en_core_web_sm /path/to/file.csv -F

Argument annotations are a tuple of the argument description (displayed when you call --help on the command line), the argument style (positional, option, flag), a shortcut (e.g. m so you can use both -m and --spacy-model on the command line) and an optional argument type or converter function that’s called on the value (e.g. str will make sure the value you get back is a string, int will convert it to an int etc.).

If you still see an error, also double-check that you’re calling prodigy my_recipe and are using -F to point to the correct path to the Python file (see example above).

Thanks a million! Seems like I was totally wrong on that one! It definitely makes more sense like this! I still got an error with the spacy_model though… I do not however need it and it works without it so problem solved!

Fixed in v1.4.2 – sorry again!