Calling packaged custom recipes


We were looking at packaging our custom recipes (nothing fancy!), and have that package pip install-ed in our various projects.

But here's the thing : unless I'm missing something, I do not see a way to call prodigy my-recipe -F my_package, because it seems -F only wants to resolve to a file path.

I could find the file actual file path, but that implies a little too much hard coding for my taste, e.g.

  {actual_package}/{file with all recipes}.py

seems really error prone (with or without the virtual env).

Am I missing something ?
Any suggestions ?

(I guess I can "fool" the file resolution by creating a local .py file that will import all my custom recipes but I'd rather get advice before trying to find work arounds)

Hi! If you're using a Python package, Prodigy actually has a built-in mechanism that lets you expose your recipes via entry points: This means that if your package is installed in the same environment as Prodigy and exposes entry points of the group prodigy_recipes, Prodigy will automatically find them and load them – without you having to import your package at all.

If you haven't worked with entry points before, this blog post is a great intro:

And here's an example of our sense2vec package exposing custom recipes via entry points in its setup.cfg: The syntax is package:module.function, so sense2vec:prodigy_recipes.teach will expose the function teach in in the sense2vec module.

1 Like

Oh I forgot about that!

Of course it works like a charm. No messing around with file names or imports.