Skip to content

Debugging the code when ValueError: Required attribute: occurs

Giacomo Marchioro edited this page Mar 10, 2022 · 1 revision

It should be quite clear where the error happens during the insertion of an invalid value through the iiifpapi module. However, missing Required statements need some tools to solve them because they are checked when the manifest/collection is written in the JSON file hence the error does not show exactly when the error occurred.

The suggested approach is the following:

  1. Open ipython console
  2. run your script using %run myscript.py
  3. activate the debug tool using %debug
  4. press u and enter until you see the frame where the manifest/collection is defined e.g. mymanifest.json_save("SFMAG_manifest30.json")
  5. now use .show_errors_in_browser() function on the istance of your manifest/collection e.g. mymanifest.show_errors_in_browser()
  6. A new tab in the browser should open (try to execute the command again if it does not).
  7. You can use your browser built-in search tool for searching the ❌Required string this will bring you exactly where the error occurred
  8. Now you can modify your script for correcting the error easily.