Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#1802 closed defect (fixed)

wcst_import should report an error on invalid option

Reported by: Dimitar Misev Owned by: ahambasan
Priority: critical Milestone: 9.7
Component: wcst_import Version: development
Keywords: Cc: Vlad Merticariu
Complexity: Medium

Description (last modified by Dimitar Misev)

If a user specifies an option that is not recognized by wcst_import, then wcst_import should throw an error instead of ignoring the option.

Furthermore, validating options seems to be duplicated in each recipe now. For common options this should be refactored into methods in the BaseRecipe class.

The code to validate ingredients files exist in several recipes files, method validate() in applications/wcst_import/recipes/*/recipe.py

Change History (7)

comment:1 by Dimitar Misev, 6 years ago

Description: modified (diff)

comment:2 by Dimitar Misev, 6 years ago

Perhaps something like this would be useful for the validation: https://pypi.org/project/jsonschema/

comment:3 by Bang Pham Huu, 5 years ago

The code to validate ingredients files exist in several recipes files, check validate() in recipe.py:

applications/wcst_import/recipes/*/recipe.py

comment:4 by Dimitar Misev, 5 years ago

Description: modified (diff)
Owner: changed from Bang Pham Huu to ahambasan
Status: newassigned

comment:5 by Dimitar Misev, 5 years ago

Priority: majorcritical

I'm getting this error now:

The jsonschema package is not installed, ingredient file validation will be skipped.           To enable validation please install jsonschema (sudo pip install jsonschema)
An error has occured in the execution of the program. Error Message: local variable 'jsonschema' referenced before assignment
Stack Trace: Traceback (most recent call last):
  File "/home/dimitar/rasdaman/enterprise/src-install/share/rasdaman/wcst_import/wcst_import.py", line 161, in main
    ingredients = decode_ingredients(read_ingredients())
  File "/home/dimitar/rasdaman/enterprise/src-install/share/rasdaman/wcst_import/wcst_import.py", line 144, in decode_ingredients
    validate_ingredients(ingredients)
  File "/home/dimitar/rasdaman/enterprise/src-install/share/rasdaman/wcst_import/wcst_import.py", line 90, in validate_ingredients
    jsonschema = import_jsonschema()
  File "/home/dimitar/rasdaman/enterprise/src-install/share/rasdaman/wcst_import/util/import_util.py", line 68, in import_jsonschema
    return jsonschema
UnboundLocalError: local variable 'jsonschema' referenced before assignment

This case (when jsonschema is not installed) should be a warning, not an error.

comment:6 by Dimitar Misev, 5 years ago

Resolution: fixed
Status: assignedclosed

comment:7 by Dimitar Misev, 5 years ago

"__comment__" attributes should also be allowed anywhere in the ingredients

Note: See TracTickets for help on using tickets.