Bug Report: Specifiying image_manual_modes crashes with Pydantic ConfigError

:bug: Bug description:
For the built-in image_manual interface, when the config value "image_manual_modes" is set either with prodigy.json or in a custom recipe, the following error occurs:

> prodigy image.manual test_dataset ./dataset/dataset.jsonl --loader jsonl --label PERSON
Using 1 label(s): PERSON
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/adambozson/Library/Caches/pypoetry/virtualenvs/bl-ocr-WI3q7U0s-py3.11/lib/python3.11/site-packages/prodigy/__main__.py", line 63, in <module>
    controller = recipe(*args, use_plac=True)
  File "cython_src/prodigy/core.pyx", line 868, in prodigy.core.recipe.recipe_decorator.recipe_proxy
  File "cython_src/prodigy/core.pyx", line 153, in prodigy.core.Controller.from_components
  File "cython_src/prodigy/core.pyx", line 295, in prodigy.core.Controller.__init__
  File "/Users/adambozson/Library/Caches/pypoetry/virtualenvs/bl-ocr-WI3q7U0s-py3.11/lib/python3.11/site-packages/prodigy/components/validate.py", line 89, in validate_config
    validate(Config, config, error_msg=error_msg, print_obj=False)
  File "/Users/adambozson/Library/Caches/pypoetry/virtualenvs/bl-ocr-WI3q7U0s-py3.11/lib/python3.11/site-packages/prodigy/components/validate.py", line 147, in validate
  File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic/main.py", line 1076, in pydantic.main.validate_model
  File "pydantic/fields.py", line 860, in pydantic.fields.ModelField.validate
pydantic.errors.ConfigError: field "image_manual_modes" not yet prepared so type is still a ForwardRef, you might need to call Config.update_forward_refs().

:man_walking:t4:Reproduction steps:
How can we recreate the bug?
Create a prodigy.json with contents:

   "image_manual_modes": ["rect", "polygon", "freehand"]

Then run

> prodigy image.manual my_dataset ./images --label PERSON

:desktop_computer: Environment variables:
Please provide prodigy stats or Python version/OS/Prodigy version:

============================== ✨  Prodigy Stats ==============================

Version          1.12.7                        
Location         /Users/adambozson/Library/Caches/pypoetry/virtualenvs/bl-ocr-WI3q7U0s-py3.11/lib/python3.11/site-packages/prodigy
Prodigy Home     /Users/adambozson/.prodigy    
Platform         macOS-13.5.1-arm64-arm-64bit  
Python Version   3.11.4                        
Spacy Version    3.6.1                         
Database Name    SQLite                        
Database Id      sqlite                        
Total Datasets   1                             
Total Sessions   7 

Pydantic version: 1.10.12

Hi Adam!

I just ran this locally on our main branch:

PRODIGY_CONFIG_OVERRIDES='{"image_manual_modes": ["rect", "polygon", "freehand"]}' python -m prodigy image.manual issue-6742 tests/images --label FOOBAR

And it gave the same error. Since the bug is reproducible I'll go ahead and attempt a fix right away.

For you right now though, the recipe should still run without the settings in the prodigy.json file. Does that mean that in the meantime you can still annotate or is there something else still blocking you? If so, I'll gladly think along to see if I can unblock what you're working on.

1 Like

Thanks Vincent.

We can continue with the default for the time being, I only wanted to use the image_manual_modes config to restrict our bounding boxes annotations to rect mode.

In the meantime I'll instruct our annotators only to use the rect tool.

Happy to hear it.

I think I've spotted the bug and that I was able to make a fix. We still need to pass the fix through reviews and all but I am hopeful that we may be able to have a patch live for this next week.

Thanks for reporting the issue!

1 Like

@adambozson good news! The new patch (v1.13.1) should have this fix.

Let me know if there's something we overlooked!

1 Like