xarray-contrib/xarray-schema

Expand Error Reporting

AdamTheisen opened this issue · 1 comments

Hello! I was just starting to work with this a bit to see if it could be used for the purposes of validating data files against our standards. One of the items that would be helpful is to improve the error reporting. I would see two things

  1. Report all differences and not just one at a time. I.e. if I have 10 errors between my object and the schema, I want to see all those and not just the first one to fail.
  2. More information would be great. As of now, it throws an error and we get the traceback like the below. It would be great if it would print out more information down to the variable tested. Something like
    lat: Expected: float32.   Found:  U32
    lon: Expected: float32.   Found:  U32
    time: Variable expected but not found

Traceback error currently reporting

Traceback (most recent call last):
  File "/Users/atheisen/Code/development-space/arm_data_validator.py", line 33, in <module>
    schema_lat.validate(ds['lat'])
  File "/opt/anaconda3/lib/python3.10/site-packages/xarray_schema/dataarray.py", line 196, in validate
    self.dtype.validate(da.dtype)
  File "/opt/anaconda3/lib/python3.10/site-packages/xarray_schema/components.py", line 29, in validate
    raise SchemaError(f'dtype {dtype} != {self.dtype}')
xarray_schema.base.SchemaError: dtype <U32 != float32

I just started using xarray-schema, and this would be extremely useful.