Custom progress reporting - get annotation stats and progress output in python code?

The builtin recipes for stats and progress are great, and I like that I can run the stats option without formatting to get the data I want.

Is there any way to call these recipes from python code, so the output could be used in custom reporting? Or is there a better approach for that than using the existing recipes? The documentation says they are command-line only.

How hard would it be to add a no format option to the progress recipe, or implement something equivalent?

Hi @rlskoeser,

Glad to hear stats and progress commands are being useful in your workflow!
Since these are just python functions, you can definitely import them just like any other function from prodigy package and call them from your code:

from prodigy.recipes.commands import progress, stats

output_progress = progress(["test"])
print(output) # [['Aug 2024', 6, 3, 6, 3]]

output_stats = stats(no_format=True)

Since it's not part of the official API, you'd have to look at the actual implementation to check the exact signature and/or potentially modify something like add a flag to disable stdout or something else.
You can consult the source of these commands in your Prodigy installation path (you can double check where that was by running prodigy stats) and then prodigy/recipes/commands.py

Let me know if that doesn't do the job for you :slight_smile:

1 Like

Thanks for this solution, I haven't had time to do more than experiment briefly but this looks like exactly what I needed.

1 Like